In that order - years, months, days
=DateDiff("mmddyyyy",[BirthDate],Now())+(Format([BirthDate],"mmddyyyy")>Format(Now(),"mmddyyyy"))
I got the above from a post but when I try it I get #Error
Help
Janet
|
|
0
|
|
|
|
Reply
|
Utf
|
1/31/2008 9:16:03 PM |
|
"mmddyyyy" is not valid for the Interval argument for the DateDiff() function!
You have to choose a single date component, and for this kind of thing it has
to the the lowest common denominator, Day.
You then have to parse the years/months/days out based on the days in a year,
days in a month and the remaining days. Because all months are not created
equal, some having 30 days, some having 31 days and February having varying
days, depending on whether or not it's a leap year, you'll have to compromise
and decide which on value to use for days in a month in order to do this.
--
There's ALWAYS more than one way to skin a cat!
Answers/posts based on Access 2000/2003
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200801/1
|
|
0
|
|
|
|
Reply
|
Linq
|
1/31/2008 10:37:04 PM
|
|
On Thu, 31 Jan 2008 13:16:03 -0800, Grams wrote:
> In that order - years, months, days
> =DateDiff("mmddyyyy",[BirthDate],Now())+(Format([BirthDate],"mmddyyyy")>Format(Now(),"mmddyyyy"))
> I got the above from a post but when I try it I get #Error
>
> Help
> Janet
Check "A More Complete DateDiff Function" at
http://www.accessmvp.com/djsteele/Diff2Dates.html
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
|
|
0
|
|
|
|
Reply
|
fredg
|
1/31/2008 10:57:53 PM
|
|
?Diff2Dates("ymd", #06/01/1998#, #06/26/2002#, True)
Okay. This is what I got from the link you sent me to. I don't want those
particular dates in there. My field is called [Birthdate]. So how would that
look calculating from today's date and using my fieldname. I tried replacing
the 06/01/1998 with the field and 06/26/2002 with Now() and Date(), but got
errors on all tries. Do I need the # signs in there? It won't work no
matter what I try
Janet
"fredg" wrote:
> On Thu, 31 Jan 2008 13:16:03 -0800, Grams wrote:
>
> > In that order - years, months, days
> > =DateDiff("mmddyyyy",[BirthDate],Now())+(Format([BirthDate],"mmddyyyy")>Format(Now(),"mmddyyyy"))
> > I got the above from a post but when I try it I get #Error
> >
> > Help
> > Janet
>
> Check "A More Complete DateDiff Function" at
> http://www.accessmvp.com/djsteele/Diff2Dates.html
>
> --
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail
>
|
|
0
|
|
|
|
Reply
|
Utf
|
1/31/2008 11:17:01 PM
|
|
On Thu, 31 Jan 2008 15:17:01 -0800, Grams wrote:
> ?Diff2Dates("ymd", #06/01/1998#, #06/26/2002#, True)
> Okay. This is what I got from the link you sent me to. I don't want those
> particular dates in there. My field is called [Birthdate]. So how would that
> look calculating from today's date and using my fieldname. I tried replacing
> the 06/01/1998 with the field and 06/26/2002 with Now() and Date(), but got
> errors on all tries. Do I need the # signs in there? It won't work no
> matter what I try
>
> Janet
>
> "fredg" wrote:
>
>> On Thu, 31 Jan 2008 13:16:03 -0800, Grams wrote:
>>
>>> In that order - years, months, days
>>> =DateDiff("mmddyyyy",[BirthDate],Now())+(Format([BirthDate],"mmddyyyy")>Format(Now(),"mmddyyyy"))
>>> I got the above from a post but when I try it I get #Error
>>>
>>> Help
>>> Janet
>>
>> Check "A More Complete DateDiff Function" at
>> http://www.accessmvp.com/djsteele/Diff2Dates.html
>>
>> --
>> Fred
>> Please respond only to this newsgroup.
>> I do not reply to personal e-mail
>>
It does work.
In my Debug Window using your dates:
?Diff2Dates("ymd", #06/01/1998#, #06/26/2002#, True)
4 years 0 months 25 days
Using your [Birthdate] field .....
In your query add a new column.
ElapsedPeriod:Diff2Dates("ymd", [Birthdate], Date(), True)
If you wish to do this directly on a form or Report, then add an
unbound control.
Set it's control source to:
= Diff2Dates("ymd", [Birthdate], Date(), True)
Using my data, with a Birthdate value of 5/24/2007, my text control
value is "0 years 8 months 7 days" from then to today.
Change the True to False and the value is
8 months 7 days.
Open the module into which you pasted the function.
Click on Debug + Compile
It should not return any errors.
Make sure the name of the module into which you pasted the function
does not have the same name as the function (i.e. NOT Diff2Dates.
mdlDiff2Dates is OK).
Now try it again in a query.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
|
|
0
|
|
|
|
Reply
|
fredg
|
1/31/2008 11:54:11 PM
|
|
|
4 Replies
1353 Views
(page loaded in 0.246 seconds)
Similiar Articles: calculate age in years, months, days - microsoft.public.access ..."mmddyyyy" is not valid for the Interval argument for the DateDiff() function! You have to choose a single date component, and for this kind of thing it has to the ... Excel - Calculate age from DOB in years, months days - microsoft ...Might seem obvious but I can't find an answer in Excel Help. I am trying to calculate age in years, months and days by subtracting cell containing ... calculate age in query - microsoft.public.accessIn that order - years, months, days =DateDiff("mmddyyyy",[BirthDate],Now())+(Format([BirthDate],"mmddyyyy")>Format(Now(),"mmddyyyy")) I got the above ... Calculating someones age - microsoft.public.access.forms ...I am using Access 2007 and I want to calculate a persons age in years, months and days on a form. I have a DOB field. Is there an easy formula I can ... Calculate Gestational Age based on months and weeks - microsoft ...calculate age in years, months, days - microsoft.public.access ... You then have to parse the years/months/days out based on the days in a ... Calculator Showing Age in ... Calculating age at different points in time - microsoft.public ...Excel - Calculate age from DOB in years, months days - microsoft ... Calculating age at different points in time - microsoft.public ... Calculating age in a Word template ... Years and Months age calculation? - microsoft.public.access.forms ...Excel - Calculate age from DOB in years, months days - microsoft ... Calculating age in a Word template/Form from the DOB field ... Excel - Calculate age from DOB in years ... How do I calculate a persons age from birth dates - microsoft ...this will do age Put your birthday in cell A1 and test =DATEDIF(A1,TODAY(),"Y") & " Years old " this will do years months and days =DATEDIF(A1,TODAY(),"Y") & " Years ... Calculating Age in Access - microsoft.public.access.gettingstarted ...calculate age in years, months, days - microsoft.public.access ... "mmddyyyy" is not valid for the Interval argument for the DateDiff() function! How to calculate diffrence between two dates - microsoft.public ...Here is a link to code for calculating age in years, months, and days (the detailed version at the bottome of the page). It can be adapted to work with the start date ... Online age calculator, calculate your birthdayKnow your age. Calculate your age in days, years ... Age Calculator; Monthly Calendar; Day of year; Adding days to date; Days between date; Days in month Calculator Showing Age in Days Weeks Months Since BirthBy Disabled World - 2008-08-02. Calculate how long you have lived for in days, weeks, months, and years since your birth date. * * * Current Age Since Born Calculator Calculate the Age of a Person in Years, Months and Days | FileMakerCalculate the Age of a Person in Years, Months and Days. How can I calculate someone's age in years, months and days? Answer ID: 5532 Last Updated: Oct 04, 2011 11:59 ... Date Duration Calculator: Days between two datesThe duration calculator calculates the difference in number of days, months and years between two dates. tsql - How to calculate age in T-SQL with years, months, and days ...What would be the best way to calculate someone's age in years, months, and days in T-SQL (SQL Server 2000)? The datediff function doesn't handle year boundaries well ... 7/25/2012 9:57:46 AM
|