473,385 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

AGE DATE

This has apparently been done many times, but everything I've looked at
is either incomprehensible or simply doesn't work.

This doesn't work on my report: datediff("yyyy",[DOB],now())

Nor does this: =datediff("yyyy",[DOB],now())

Can anyone suggest why?

There are many other suggestions as to how to do this, but I can't get
any to work. I just want to enter the age in a report field based on
someone date of birth = DOB as fieldname.

Sep 8 '06 #1
12 1519
ch**********@isuga.fr wrote:
This has apparently been done many times, but everything I've looked at
is either incomprehensible or simply doesn't work.

This doesn't work on my report: datediff("yyyy",[DOB],now())

Nor does this: =datediff("yyyy",[DOB],now())
That one should work.

Is the DOB field empty?

You don't say what doesn't work so it's hard to determine what is wrong
>
Can anyone suggest why?

There are many other suggestions as to how to do this, but I can't get
any to work. I just want to enter the age in a report field based on
someone date of birth = DOB as fieldname.
Sep 8 '06 #2
Hard to tell what the problem is, but I can tell you right now you're
not always going to get an accurate answer using that formula. If the
date is Sept 9 and the person was born Oct 4, he's going to appear to
be a year older than he really is.

ch**********@isuga.fr wrote:
This has apparently been done many times, but everything I've looked at
is either incomprehensible or simply doesn't work.

This doesn't work on my report: datediff("yyyy",[DOB],now())

Nor does this: =datediff("yyyy",[DOB],now())

Can anyone suggest why?

There are many other suggestions as to how to do this, but I can't get
any to work. I just want to enter the age in a report field based on
someone date of birth = DOB as fieldname.
Sep 8 '06 #3
I use a function to display age:
(caution - air code)

Public Function Age(Bdate as date) as integer
Age = Year(Date) - Year(Bdate)
' Subtract 1 if subject hasn't yet had their birthday this year
If Format(Date,'mmdd') < Format(Bdate,'mmdd') Then
Age = Age - 1
Endif
End Function

Fred Zuckerman
"ManningFan" <ma********@gmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
Hard to tell what the problem is, but I can tell you right now you're
not always going to get an accurate answer using that formula. If the
date is Sept 9 and the person was born Oct 4, he's going to appear to
be a year older than he really is.

ch**********@isuga.fr wrote:
This has apparently been done many times, but everything I've looked at
is either incomprehensible or simply doesn't work.

This doesn't work on my report: datediff("yyyy",[DOB],now())

Nor does this: =datediff("yyyy",[DOB],now())

Can anyone suggest why?

There are many other suggestions as to how to do this, but I can't get
any to work. I just want to enter the age in a report field based on
someone date of birth = DOB as fieldname.

Sep 8 '06 #4
On Fri, 08 Sep 2006 20:39:43 GMT, "Fred Zuckerman"
<Zu********@sbcglobal.netwrote:
>I use a function to display age:
(caution - air code)

Public Function Age(Bdate as date) as integer
Age = Year(Date) - Year(Bdate)
' Subtract 1 if subject hasn't yet had their birthday this year
If Format(Date,'mmdd') < Format(Bdate,'mmdd') Then
Age = Age - 1
Endif
End Function

Fred Zuckerman
Or, perhaps

Age=Year(Date) - Year(Bdate) + _
(DatePart("y",Date) < DatePart("y",Bdate))

-=-=-=-=-=-=-=-=-=-=-=-=
Randy Harris
tech at promail dot com
Sep 9 '06 #5
How about something simple like:

intAge = Int( (Now() - BDate) / 365 )
<ch**********@isuga.frwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
This has apparently been done many times, but everything I've looked at
is either incomprehensible or simply doesn't work.

This doesn't work on my report: datediff("yyyy",[DOB],now())

Nor does this: =datediff("yyyy",[DOB],now())

Can anyone suggest why?

There are many other suggestions as to how to do this, but I can't get
any to work. I just want to enter the age in a report field based on
someone date of birth = DOB as fieldname.

Sep 10 '06 #6

"Kc-Mass" <co********@comcast.netschreef in bericht news:BJ******************************@comcast.com. ..
How about something simple like:

intAge = Int( (Now() - BDate) / 365 )
Only if *every* year would have 365 days this would be a correct answer...

Arno R
Sep 10 '06 #7

"Arno R" <ar***********@tiscali.nlwrote in message
news:45**********************@text.nova.planet.nl. ..
intAge = Int( (Now() - BDate) / 365 )
Only if *every* year would have 365 days this would be a correct answer...

-----

Seems OK to me. By the time the error creeps in enough to kick that INT up
to the next number, a person would have to be over 700 years old (having
lived for over 183 leap years).

I could be wrong, though...

Armando
Sep 22 '06 #8
"Armando" <ar*****@bogus.comwrote in
news:ya*******************@news1.epix.net:
>
"Arno R" <ar***********@tiscali.nlwrote in message
news:45**********************@text.nova.planet.nl. ..
> intAge = Int( (Now() - BDate) / 365 )

Only if *every* year would have 365 days this would be a
correct answer...

-----

Seems OK to me. By the time the error creeps in enough to
kick that INT up to the next number, a person would have to be
over 700 years old (having lived for over 183 leap years).

I could be wrong, though...

Armando
testing your expression against age() at
http://www.mvps.org/access/datetime/date0001.htm,
with now() at 22/09/2006 6:37:03 PM

gives the first error
23/09/1996 (7302 days ago)
and subsequent errors at
25/09/1995 8030
24/09/1995 8032
23/09/1995 8034
25/09/1994 8760
24/09/1994 8762
23/09/1994 8764
25/09/1993 9490
24/09/1993 9492
23/09/1993 9494

I just looped to 10000 days.

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Sep 22 '06 #9

"Armando" <ar*****@bogus.comschreef in bericht news:ya*******************@news1.epix.net...

"Arno R" <ar***********@tiscali.nlwrote in message
news:45**********************@text.nova.planet.nl. ..
> intAge = Int( (Now() - BDate) / 365 )
Only if *every* year would have 365 days this would be a correct answer...

-----

Seems OK to me. By the time the error creeps in enough to kick that INT up
to the next number, a person would have to be over 700 years old (having
lived for over 183 leap years).

I could be wrong, though...

Armando
You are wrong indeed.

Suppose my birthday is today and I was born 23-09-1951
Your function would say that I am 55 years old correct

Suppose my birthday was not today but tomorrow...
Your function would say that I am 55 years old wrong

Suppose my birthday was not today but 1day after tomorrow...
Your function would say that I am 55 years old wrong
Suppose my birthday was not today but 2days after tomorrow...
Your function would say that I am 55 years old wrong
Suppose my birthday was not today but 3days after tomorrow...
Your function would say that I am 55 years old wrong
Suppose my birthday was not today but 4days after tomorrow...
Your function would say that I am 55 years old wrong
Suppose my birthday was not today but 5days after tomorrow...
Your function would say that I am 55 years old wrong
Suppose my birthday was not today but 6days after tomorrow...
Your function would say that I am 55 years old wrong
....
Suppose my birthday was not today but 10days after tomorrow...
Your function would say that I am 55 years old wrong
....
For how many days your function will be wrong ???
Too many !!

This is a repeating issue EACH year !!

Arno R

Sep 23 '06 #10

Arno R wrote:
"Armando" <ar*****@bogus.comschreef in bericht news:ya*******************@news1.epix.net...

"Arno R" <ar***********@tiscali.nlwrote in message
news:45**********************@text.nova.planet.nl. ..
intAge = Int( (Now() - BDate) / 365 )
Only if *every* year would have 365 days this would be a correct answer...

-----

Seems OK to me. By the time the error creeps in enough to kick that INT up
to the next number, a person would have to be over 700 years old (having
lived for over 183 leap years).

I could be wrong, though...

Armando

You are wrong indeed.

Suppose my birthday is today and I was born 23-09-1951
Suppose my birthday was not today but 6days after tomorrow...
Your function would say that I am 55 years old wrong
...
Suppose my birthday was not today but 10days after tomorrow...
Your function would say that I am 55 years old wrong
...
For how many days your function will be wrong ???
Too many !!

This is a repeating issue EACH year !!
yes, and the number of days per year where the expression is wrong is
equal to the number of leap years in the interval between birthday and
now().

Interestingly, changing the divisor to 365.25 reduces the error to a
single day in two years of four. (2 years of error, two years no error,
recurring)

Arno R
Sep 23 '06 #11

"rq******@sympatico.ca" <bo*********@gmail.comschreef in bericht news:11**********************@m73g2000cwd.googlegr oups.com...

Interestingly, changing the divisor to 365.25 reduces the error to a
single day in two years of four. (2 years of error, two years no error,
recurring)
Hi Bob,

Yes, this math is *much* better, but still wrong ...
Since we can use a function that we can rely on, we don't need to use an expression that is not reliable.

Arno R
Sep 24 '06 #12

Arno R wrote:
"rq******@sympatico.ca" <bo*********@gmail.comschreef in bericht news:11**********************@m73g2000cwd.googlegr oups.com...

Interestingly, changing the divisor to 365.25 reduces the error to a
single day in two years of four. (2 years of error, two years no error,
recurring)

Hi Bob,

Yes, this math is *much* better, but still wrong ...
Since we can use a function that we can rely on, we don't need to use an expression that is not reliable.

Arno R
I'm in complete agreement.

Sep 24 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does anybody have an idea how I can make it work again or...
9
by: Thomas R. Hummel | last post by:
Hello, I am importing data that lists rates for particular coverages for a particular period of time. Unfortunately, the data source isn't very clean. I've come up with some rules that I think...
30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
3
by: captain | last post by:
Below is the sql for data with same date need to extract + or - 5 days data of same date also. How to also get data of + and - days related to same date. SELECT IM.Area, IM.Location,...
1
by: Liz Malcolm | last post by:
Hello and TIA. I have a DE form with an option group that if daily is selected todays date is used for start and end date, if weekly is selected Monday - Friday is used. I am trying to add a...
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
3
by: JJ | last post by:
Here's the code. $link="http://xbox360cheat.org"; $close_date=$_POST; #last content change check if ($close_date == 0) $close_date = date("Y-m-d H:m:s", mktime(12, 0, 0, date("m"), date...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.