A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

age rounding up or down



 
 
Thread Tools Display Modes
  #1  
Old September 16th, 2009, 05:19 PM posted to microsoft.public.access.queries
Abe
external usenet poster
 
Posts: 39
Default age rounding up or down

I'm using this formula from the office help to calculate a birthdate:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") Format(
[Birthdate], "mmdd") )

My fields have the same name, but my query is outputting the wrong age -
rounding up or down. How can I make it exact?
--
Thanks, Abe
  #2  
Old September 16th, 2009, 06:01 PM posted to microsoft.public.access.queries
Klatuu
external usenet poster
 
Posts: 7,074
Default age rounding up or down

CalcAge = DateDiff("yyyy", BirthDate, DateToday) _
- IIf(Format(DateToday, "mmdd") Format(BirthDate, "mmdd"), 1, 0)

--
Dave Hargis, Microsoft Access MVP


"Abe" wrote:

I'm using this formula from the office help to calculate a birthdate:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") Format(
[Birthdate], "mmdd") )

My fields have the same name, but my query is outputting the wrong age -
rounding up or down. How can I make it exact?
--
Thanks, Abe

  #3  
Old September 16th, 2009, 06:05 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default age rounding up or down

On Wed, 16 Sep 2009 09:19:02 -0700, Abe wrote:

I'm using this formula from the office help to calculate a birthdate:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") Format(
[Birthdate], "mmdd") )

My fields have the same name, but my query is outputting the wrong age -
rounding up or down. How can I make it exact?


The expression returns the age in years as an integer. I turned 63 on May 16,
and I'll be 63 until May 16 next year. That's the purpose of the expression!

What do you have in Birthdate? What is it that you're trying to calculate (you
say "to calculate a birthdate" but the expression assumes you HAVE a
birthdate).

Please explain what you have and what you want.
--

John W. Vinson [MVP]
  #4  
Old September 16th, 2009, 07:36 PM posted to microsoft.public.access.queries
Abe
external usenet poster
 
Posts: 39
Default age rounding up or down

Sorry I wasn't clear. I'm trying to get the age, but that formula didn't
return the exact age, it made the person younger or older depending on the
proximity of the current month. I got the answer in the next post though!
--
Thanks anyway, Abe


"John W. Vinson" wrote:

On Wed, 16 Sep 2009 09:19:02 -0700, Abe wrote:

I'm using this formula from the office help to calculate a birthdate:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") Format(
[Birthdate], "mmdd") )

My fields have the same name, but my query is outputting the wrong age -
rounding up or down. How can I make it exact?


The expression returns the age in years as an integer. I turned 63 on May 16,
and I'll be 63 until May 16 next year. That's the purpose of the expression!

What do you have in Birthdate? What is it that you're trying to calculate (you
say "to calculate a birthdate" but the expression assumes you HAVE a
birthdate).

Please explain what you have and what you want.
--

John W. Vinson [MVP]

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.