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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateDiff troubles.

Status
Not open for further replies.

amy3000

Technical User
Sep 25, 2000
59
US
I've looked at past posts but still need help.

I used this expression successfully in a query to determine the age of a woman at the time of the birth of her baby. M DOB is her birthdate and EDC is the delivery date.
Expr1: DateDiff("yyyy",[M DOB],[EDC])

Now I need to figure out the kids' ages at discharge from our program (public health nursing). Unfortunately, in their wisdom, the creators of the form did not have a place to write the discharge date. So I don't have an equivalent field to EDC for the kids.

I was going to choose an arbritrary date in 2000 like 6/15/00 as the discharge date for all the kids. I can't figure out how to write the expression. It would be best to have the kids age in months since most will be under 1 year.

Can someone tell me how to write this expression in a query correctly?

DateDiff(months, [child's birthday], [6/15/00])

Any reccomendations for a good reference book for Access 2000. I bought the Access 2000 Bible but it has a terrible index. The answers may be there but I sure can't find them.

Thanks
 
DateDiff("m", [child's birthday], #6/15/00#)
If you will lookup datediff in Access help you will see it explains in nice detail how to use the function.
 
Yes, ... but ... as recently discussed in this forum, datediff can yield ? strsange? results. For the "interval" [YYYY | D | H | ...] you need to CAREFULLY check how the results "Interval Boundaries" crossed. e.g.

datediff ("y", #12/31/2000", #1/1/2001#)
Returns 1

datediff("m", #10/31/2001#, #1/11/2001#)
Returns 1

... let the buyer beware ...


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top