PC Review


Reply
Thread Tools Rate Thread

addin or subtracting dates before 1900??

 
 
=?Utf-8?B?YW1rbm9ycg==?=
Guest
Posts: n/a
 
      18th Jul 2007
I geneaology work we have to work with dates prior to 1900. How can I find
the age of a person born in 1893 who expired in 1960?
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      18th Jul 2007
See the Age() function here:
http://allenbrowne.com/func-08.html

You can pass in the death date as the 2nd parameter, e.g.:
? Age([BirthDate], [DeathDate])
If the person hasn't died yet, it returns their age as of today.

DateDiff() can calculate a difference in years, but you need to adjust if
the person has not had their birthday in the year they died.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"amknorr" <(E-Mail Removed)> wrote in message
news:F3CC4797-3139-4DC2-86DB-(E-Mail Removed)...
>I geneaology work we have to work with dates prior to 1900. How can I find
> the age of a person born in 1893 who expired in 1960?


 
Reply With Quote
 
=?Utf-8?B?UGl4aWU3OA==?=
Guest
Posts: n/a
 
      18th Jul 2007
I was just reading about this and made a sample for to see if it worked for
dates before 1900 and it does. Use DateDiff. Here is the code you would use
in a text box control source of your form or report.

=DateDiff("yyyy", [DOB], [DOE])

the "yyyy" will calculate the time is years. "d" Days and so on. DOB would
be the name of your field for Date of Birth and I used DOE for the name of
your field for Date of Expiration.
I used it just now to make sure it worked before I posted it to you and it
does. I put in several different dob's in the 1800's and all the date of
deaths over 1900 and it works great.

"amknorr" wrote:

> I geneaology work we have to work with dates prior to 1900. How can I find
> the age of a person born in 1893 who expired in 1960?

 
Reply With Quote
 
Pat Hartman \(MVP\)
Guest
Posts: n/a
 
      18th Jul 2007
Keep in mind that you will always want to display four-digit years in this
application since you are working with data that spans centuries.

"amknorr" <(E-Mail Removed)> wrote in message
news:F3CC4797-3139-4DC2-86DB-(E-Mail Removed)...
>I geneaology work we have to work with dates prior to 1900. How can I find
> the age of a person born in 1893 who expired in 1960?



 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      18th Jul 2007
On Wed, 18 Jul 2007 09:00:00 -0700, Pixie78
<(E-Mail Removed)> wrote:

>I was just reading about this and made a sample for to see if it worked for
>dates before 1900 and it does. Use DateDiff. Here is the code you would use
>in a text box control source of your form or report.
>
>=DateDiff("yyyy", [DOB], [DOE])
>
>the "yyyy" will calculate the time is years. "d" Days and so on. DOB would
>be the name of your field for Date of Birth and I used DOE for the name of
>your field for Date of Expiration.


That will be close... but not absolutely accurate, at least by the traditional
use of "age". DateDiff actually counts year (or day, or second, or...)
boundaries, not full years; so if [DOB] were 12/31/1875 and [DOE] were
1/1/1876 - just a day later - the age would be reported as one year. Or if
[DOB] were 1/1/1931 and [DOE] 12/29/1931 - almost a year - you'ld still get 0.

You can correct for this with an expression:

DateDiff("yyyy", [DOB], [DOE]) - IIF(Format([DOE], "mmdd") > Format([DOB],
"mmdd"), 1, 0)


John W. Vinson [MVP]
 
Reply With Quote
 
Pieter Wijnen
Guest
Posts: n/a
 
      25th Sep 2007
Or simplified to

DateDiff("yyyy", [DOB], [DOE]) + (Format([DOE], "mmdd") > Format([DOB],
"mmdd"))

I love Boolean expressions <g>

Pieter


"John W. Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news:(E-Mail Removed)...
> On Wed, 18 Jul 2007 09:00:00 -0700, Pixie78
> <(E-Mail Removed)> wrote:
>
>>I was just reading about this and made a sample for to see if it worked
>>for
>>dates before 1900 and it does. Use DateDiff. Here is the code you would
>>use
>>in a text box control source of your form or report.
>>
>>=DateDiff("yyyy", [DOB], [DOE])
>>
>>the "yyyy" will calculate the time is years. "d" Days and so on. DOB
>>would
>>be the name of your field for Date of Birth and I used DOE for the name of
>>your field for Date of Expiration.

>
> That will be close... but not absolutely accurate, at least by the
> traditional
> use of "age". DateDiff actually counts year (or day, or second, or...)
> boundaries, not full years; so if [DOB] were 12/31/1875 and [DOE] were
> 1/1/1876 - just a day later - the age would be reported as one year. Or if
> [DOB] were 1/1/1931 and [DOE] 12/29/1931 - almost a year - you'ld still
> get 0.
>
> You can correct for this with an expression:
>
> DateDiff("yyyy", [DOB], [DOE]) - IIF(Format([DOE], "mmdd") > Format([DOB],
> "mmdd"), 1, 0)
>
>
> John W. Vinson [MVP]



 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      25th Sep 2007
On Tue, 25 Sep 2007 17:21:26 +0200, "Pieter Wijnen"
<(E-Mail Removed)>
wrote:

>Or simplified to
>
>DateDiff("yyyy", [DOB], [DOE]) + (Format([DOE], "mmdd") > Format([DOB],
>"mmdd"))
>
>I love Boolean expressions <g>


That's what I used to use... until someone pointed out that in SQL/Server True
is +1 rather than -1. The IIF is at least platform independent!

John W. Vinson [MVP]
 
Reply With Quote
 
Pieter Wijnen
Guest
Posts: n/a
 
      25th Sep 2007
Didnt' know SQLServer had IIf, Format & DateDiff <g>
the statement will only be valid in VBA anyway

Pieter


"John W. Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news:(E-Mail Removed)...
> On Tue, 25 Sep 2007 17:21:26 +0200, "Pieter Wijnen"
> <(E-Mail Removed)>
> wrote:
>
>>Or simplified to
>>
>>DateDiff("yyyy", [DOB], [DOE]) + (Format([DOE], "mmdd") > Format([DOB],
>>"mmdd"))
>>
>>I love Boolean expressions <g>

>
> That's what I used to use... until someone pointed out that in SQL/Server
> True
> is +1 rather than -1. The IIF is at least platform independent!
>
> John W. Vinson [MVP]



 
Reply With Quote
 
Pieter Wijnen
Guest
Posts: n/a
 
      25th Sep 2007
and using Abs is always an option <g> - I Still love Boolean math
DateDiff("yyyy", [DOB], [DOE]) - Abs(Format([DOE], "mmdd") > Format([DOB],
"mmdd"))

It doesn't get really tricky 'till you move to Oracle (PL/SQL) That does
really have the concepts TRUE & FALSE

Pieter

"John W. Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news:(E-Mail Removed)...
> On Tue, 25 Sep 2007 17:21:26 +0200, "Pieter Wijnen"
> <(E-Mail Removed)>
> wrote:
>
>>Or simplified to
>>
>>DateDiff("yyyy", [DOB], [DOE]) + (Format([DOE], "mmdd") > Format([DOB],
>>"mmdd"))
>>
>>I love Boolean expressions <g>

>
> That's what I used to use... until someone pointed out that in SQL/Server
> True
> is +1 rather than -1. The IIF is at least platform independent!
>
> John W. Vinson [MVP]



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dates before 1900 Cordlina Microsoft Excel Misc 2 22nd Dec 2009 01:43 PM
Dates before 1900 clueless in nj Microsoft Excel Worksheet Functions 2 9th Dec 2007 08:49 PM
No dates before 1900?! JMF Microsoft Excel Discussion 3 28th Mar 2006 01:08 PM
Dates before 1900 =?Utf-8?B?Y2hyaXM=?= Microsoft Excel Worksheet Functions 2 28th Apr 2004 12:26 PM
Dates before 1900???? SLICKERS Raingear Warehouse Microsoft Excel Misc 2 24th Dec 2003 09:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:10 AM.