PC Review


Reply
Thread Tools Rate Thread

Access date to age

 
 
=?Utf-8?B?c2tyeXNpYWs=?=
Guest
Posts: n/a
 
      9th Nov 2007
is there any way to calculate age from 2 date fields in years
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      9th Nov 2007
See this function:
http://allenbrowne.com/func-08.html

It takes 2 dates, and gives the age (in whole years) as of a particular
date.

--
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.

"skrysiak" <(E-Mail Removed)> wrote in message
news6A7BECA-C98C-4A02-AC2D-(E-Mail Removed)...
> is there any way to calculate age from 2 date fields in years


 
Reply With Quote
 
James A. Fortune
Guest
Posts: n/a
 
      9th Nov 2007
skrysiak wrote:
> is there any way to calculate age from 2 date fields in years


For the age in years from dt1 to dt2 I use (VBA):

intCurrentAge = Int(Format(dt2, "yyyy.mmdd") - Format(dt1, "yyyy.mmdd"))

In SQL:

SELECT Int(Format(Date(), "yyyy.mmdd") - Format([BirthDate],
"yyyy.mmdd")) As CurrentAge FROM MyTable WHERE BirthDate IS NOT NULL;

It makes use of a mathematical concept known as a Poset (Partially
Ordered Set) relationship where the relative order of dates making up
the actual fraction of years is the same as the numerical order of the
pseudodecimal representation of those dates given by the format function.

James A. Fortune
(E-Mail Removed)
 
Reply With Quote
 
=?Utf-8?B?TWFSU01BTg==?=
Guest
Posts: n/a
 
      9th Nov 2007


"James A. Fortune" wrote:

> skrysiak wrote:
> > is there any way to calculate age from 2 date fields in years

>
> For the age in years from dt1 to dt2 I use (VBA):
>
> intCurrentAge = Int(Format(dt2, "yyyy.mmdd") - Format(dt1, "yyyy.mmdd"))
>
> In SQL:
>
> SELECT Int(Format(Date(), "yyyy.mmdd") - Format([BirthDate],
> "yyyy.mmdd")) As CurrentAge FROM MyTable WHERE BirthDate IS NOT NULL;
>
> It makes use of a mathematical concept known as a Poset (Partially
> Ordered Set) relationship where the relative order of dates making up
> the actual fraction of years is the same as the numerical order of the
> pseudodecimal representation of those dates given by the format function.
>
> James A. Fortune
> (E-Mail Removed)
>


How would the sql look if current age I want to show 60 years,10 months,3
days
 
Reply With Quote
 
James A. Fortune
Guest
Posts: n/a
 
      9th Nov 2007
MaRSMAN wrote:
>
> "James A. Fortune" wrote:
>
>
>>skrysiak wrote:
>>
>>>is there any way to calculate age from 2 date fields in years

>>
>>For the age in years from dt1 to dt2 I use (VBA):
>>
>>intCurrentAge = Int(Format(dt2, "yyyy.mmdd") - Format(dt1, "yyyy.mmdd"))
>>
>>In SQL:
>>
>>SELECT Int(Format(Date(), "yyyy.mmdd") - Format([BirthDate],
>>"yyyy.mmdd")) As CurrentAge FROM MyTable WHERE BirthDate IS NOT NULL;
>>
>>It makes use of a mathematical concept known as a Poset (Partially
>>Ordered Set) relationship where the relative order of dates making up
>>the actual fraction of years is the same as the numerical order of the
>>pseudodecimal representation of those dates given by the format function.
>>
>>James A. Fortune
>>(E-Mail Removed)
>>

>
>
> How would the sql look if current age I want to show 60 years,10 months,3
> days


Try:

http://groups.google.com/group/micro...c1e78c092cdd13

Post back if you have trouble seeing how to follow that suggestion.

James A. Fortune
(E-Mail Removed)
 
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
Access Ver 2.0 Adding days to a date to give target date excluding weekends? michael.nilsen@sgs.com Microsoft Access Macros 1 30th Nov 2006 02:20 AM
Access Ver 2.0 Adding days to a date to give target date excluding weekends? Michael Microsoft Access Forms 2 19th Nov 2006 10:52 PM
Access Ver 2.0 Adding days to a date to give target date excluding weekends? michael.nilsen@sgs.com Microsoft Access VBA Modules 1 19th Nov 2006 01:06 PM
DataGrid + Access-DB - display date-values grouped by date and time? Olaf Rabbachin Microsoft VB .NET 1 19th May 2005 09:23 AM
Export Outlook date field as date/time format to Access database =?Utf-8?B?QmVja3k=?= Microsoft Outlook Discussion 0 2nd Dec 2004 02:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:20 PM.