PC Review


Reply
Thread Tools Rate Thread

DateDiff Partial Year Calculation

 
 
ITAnnaJones@gmail.com
Guest
Posts: n/a
 
      11th Dec 2006
I am using the DateDiff function to calculate the difference in years
between two dates to show two decimal places for a partial year result.
Any help in formatting this output correctly is appreciated.

 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      11th Dec 2006
DateDiff only returns a Long Integer.

I suppose you could have DateDiff return the number of months, and divide by
12, or the number of days, and divide by 365.25, but both of those
approaches will have inaccuracies. That's because DateDiff returns how many
"boundaries" are crossed between the two dates. What I mean by this is that
if you use DateDiff("yyyy", #12/31/2006#, #01/01/2007#) to calculate the
number of years between 31 Dec, 2006 and 01 Jan, 2007, the function will
return 1 year, even though it's only 1 day. That's because it's crossed 1
year boundary between the two dates.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am using the DateDiff function to calculate the difference in years
> between two dates to show two decimal places for a partial year result.
> Any help in formatting this output correctly is appreciated.
>



 
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
Datediff & bissextile year Basta1980 Microsoft Excel Programming 16 21st Aug 2009 09:17 AM
DateDiff Calculation Henry Stockbridge Microsoft Outlook VBA Programming 4 15th Aug 2008 12:19 AM
Re: DateDiff Calculation Off By One Year??? Per Larsen Microsoft Access Queries 1 17th Jul 2006 06:14 PM
Re: DateDiff Calculation Off By One Year??? Ronster Microsoft Access Queries 0 14th Jul 2006 09:54 PM
DateDiff and the Year 1930 Iain Scott Microsoft Access Queries 2 10th Aug 2004 08:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:50 AM.