Round Down in Microsoft Access 2000

  • Thread starter Thread starter Chrissy
  • Start date Start date
C

Chrissy

So I have been working on this form to try and calculate an age from a
birthdate. Everything I have tried has not worked. So I finally came
up with this formula and now it rounds everything up or down. I need
it to round down and I can't figure out for anything. The formula I
have is this:
=DateDiff("d",[Date of Birth],Now())/365)

How can I get this so it rounds down everytime so I can get the correct
age?
Thanks
 
Try using the following to calculated age:

=DateDiff("yyyy", [DateOfBirth], Date()) - _
IIf(Format(Date(), "mmdd") < Format([DateOfBirth], "mmdd"), 1, 0)

DateDiff is very literal. When using yyyy (to calculate the number of years
between two dates), it counts every year boundary it crosses. This means
that DateDiff("yyyy", #2006-12-31#, #2007-01-01#) is 1, even though it's
only 1 day between the two dates. To compensate for this, you need to check
whether or not the birthday has already occurred in the current year. If it
hasn't, you subtract 1 from what DateDiff tells you.
 
Awesome... I did it and it worked. thanks so much I have been trying
this forever.
Try using the following to calculated age:

=DateDiff("yyyy", [DateOfBirth], Date()) - _
IIf(Format(Date(), "mmdd") < Format([DateOfBirth], "mmdd"), 1, 0)

DateDiff is very literal. When using yyyy (to calculate the number of years
between two dates), it counts every year boundary it crosses. This means
that DateDiff("yyyy", #2006-12-31#, #2007-01-01#) is 1, even though it's
only 1 day between the two dates. To compensate for this, you need to check
whether or not the birthday has already occurred in the current year. If it
hasn't, you subtract 1 from what DateDiff tells you.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Chrissy said:
So I have been working on this form to try and calculate an age from a
birthdate. Everything I have tried has not worked. So I finally came
up with this formula and now it rounds everything up or down. I need
it to round down and I can't figure out for anything. The formula I
have is this:
=DateDiff("d",[Date of Birth],Now())/365)

How can I get this so it rounds down everytime so I can get the correct
age?
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top