Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Range Var

Status
Not open for further replies.
Joined
Jul 13, 2002
Messages
36
Location
US
I need to know specific ranges of dates of birth of our children who have received vaccinations within a given month. Therefore, I have a need to know how to declare a date range variable, something I've never done. Example: Need to know vaccines given to children, age 0-1 year, then age 2 years, 3 years, etc. How do I write the variable and formula? Technonurse-Spokane
 
Depending on your database structure, you do not need a variable to do this. For example lets say you have the following in your database:

Name DOB Vaccine Date
Child A 01-17-02 07-17-02
Child B 11-19-00 11-19-01
Child C 02-05-99 09-05-99
Child D 07-04-98 <<null>>

The you can create formulas for each age group:

@lessthan1Vaccinated
If {DOB} in Currentdate to Dateadd(&quot;y&quot;,-1,Currentdate} and
Not IsNull({VaccineDate}) then 1 else 0

@lessthan1NotVaccinated
If {DOB} in Currentdate to Dateadd(&quot;y&quot;,-1,Currentdate} and
IsNull({VaccineDate}) then 1 else 0

Write similar formulas to the above 2 for every age group you are interested in. Then group these formulas however you need to - by state, race, sex, etc.

Let me know if you have any questions.

Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
You don't need a date range variable.

You can use the datediff() function to determine the difference between 2 dates, it allows for various differences, including years, so you'd compare the birthday with currentdate:

I think it works something like this:

Create a &quot;Years Since Birth&quot; formula to group by:
datediff(&quot;yyyy&quot;,{MyTable.BirthDate}, currentdate)

This should tell you how many years have passed since the DOB.

Add into your record selection criteria a formula which limits rows to only those who've had their vacination:

{MyTable.MyVacinationFlag} = true // or however you detect this

Now you can use conventional summing and other built in math/statistic/date functions against the data in the details section of the report.

I can't test this right now, but it's close if it didn't nail it.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top