View Full Version : DateDiff


moleary
10-25-2001, 06:43 AM
I am trying to do a datediff for a query to get a age for our clients, but it is not giving me their age it is giving me a long number?? I am using datediff "y",date of birth, date(),) but it gives me something like 24975?? Does it have something to do with the century change?

DJN
10-25-2001, 07:13 AM
Try this. Age: DateDiff("yyyy",[date of birth],Now())
You need to add 3 more y's

R. Hicks
10-25-2001, 08:13 AM
This question has been covered a few times in the last week or so.

I think you will find that your method will not return the correct age. If the DOB is 1/1/54 the expression will return 47 (this is correct), but if the DOB is 12/1/54 it will again return 47 (should be 46), the birthday has not occured yet.

Use the following instead. It will always return the correct age based on the current date.

Age: DateDiff("yyyy",[date of birth],Date())+(Date()<DateSerial(Year(Date()),Month([date of birth]),Day([date of birth])))
(all of the above should be one line)

HTH
RDH

[This message has been edited by R. Hicks (edited 10-25-2001).]

moleary
10-25-2001, 08:27 AM
Thanks! I forgot about yyyy to return a age! Duh!