Susan Harkins
ssharkins at setel.com
Mon Jun 25 17:39:15 CDT 2007
That's not an error -- you can't expect date arithmetic to apply a
"business" rule, and frankly, that's what it is. The expression is returning
the correct answer, it just isn't the answer you require.
Seems like it would be easy enough to run a simple check -- if it's a Feb 29
birthdate and the date is Feb 28, add 1.
Susan H.
Hi Susan
No, same error.
/gustav
>>> ssharkins at setel.com 25-06-2007 15:48 >>>
I came up with this one years and years ago -- will it work for you?
Year(Now())-Year(date)+(DateSerial(Year(Now()),Month(date),Day(date))>Now())
Susan H.
Hi Steve
Sorry, it still fails miserably for, say, these dates:
DOB = #2/29/1992#
AtDay = #2/28/1997#
returning 4 and not 5.
/gustav
>>> miscellany at mvps.org 23-06-2007 22:57 >>>
Hehe. Answering my own question. I wouldn't mind $5 for every time I have
used that expression over the last 12 years, on the assumption that I had it
licked.
And now I see the obvious - in the case of a 29 February birthday,
evaluating age on 28 February in a non leap year works correctly, but
evaluating age on 28 February during a leap year, it gives the wrong figure.
So, I have modified accordingly...
Age: DateDiff("yyyy",[DOB],[DateAt])+(Format([DOB]+(Format([DOB],"mmdd")
=Format([DateAt],"mmdd")="0229"),"mmdd")>Format([DateAt],"mmdd"))
Regards
Steve
Steve Schapel wrote:
> However, I can't find an example where the following does not work
> correctly. Can you?
>
> Age:
> DateDiff("yyyy",[DOB],[DateAt])+(Format([DOB]+(Format([DOB],"mmdd")
> ="0229"),"mmdd")>Format([DateAt],"mmdd"))
--
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.9.1/857 - Release Date: 6/20/2007
2:18 PM