Round function? (1 Viewer)

DLS1942

New member
Local time
Today, 09:49
Joined
Dec 25, 2015
Messages
4
I have a query to calculate age from DOB, how do I round either to age last or nearest? I am using Age: DateDiff("yyyy",[DOB],Now())
Thanks,
Dan
 

plog

Banishment Pending
Local time
Today, 11:49
Joined
May 11, 2011
Messages
11,653
That's not how you calculate age. Search this forum for it (Within the last 2 weeks I was reluctantly part of a very tedious thread where everyone tried to one up each other calculating it). Actually now that I think about it, if you wait long enough you won't have to search--I'm sure at least of those 2 pedants will find this thread and start trying to show their calculating prowess again by posting code in this one. And then someone will come along to correct them ad nasuem.

I'll only give you a general help: You don't solve this with rounding. You solve it by finding the difference in years (which you have done) and then finding out if their birth month and day has already occured in the current year.
 

DLS1942

New member
Local time
Today, 09:49
Joined
Dec 25, 2015
Messages
4
Plog,
Thanks very much for your reply. I will try the search as you suggested. I always appreciate everyone's input.
Dan
 

sneuberg

AWF VIP
Local time
Today, 09:49
Joined
Oct 17, 2014
Messages
3,506
I'm sure at least of those 2 pedants will find this thread and start trying to show their calculating prowess again by posting code in this one. And then someone will come along to correct them ad nasuem..

I wasn't part of that thread, but someone needs to get the ball rolling here so here's my submission:

Age: IIf(DatePart("y",Now())>=DatePart("y",[DOB]),DateDiff("yyyy",[DOB],Now()),DateDiff("yyyy",[DOB],Now())-1)
 

DLS1942

New member
Local time
Today, 09:49
Joined
Dec 25, 2015
Messages
4
Many Thanks!!!
As you know you are Spot ON!
I Appreciate this very much!!!!!
 

Users who are viewing this thread

Top Bottom