PC Review


Reply
Thread Tools Rate Thread

Date Differences in Years

 
 
allenjc11
Guest
Posts: n/a
 
      27th May 2010
Hello,

I have the following formula in Access 2007 to determine how many years
someone has been with the company.

-----

Years of Service: DateDiff("yyyy",[Hire Date],[TodaysDate])

-----

This formula is partially accurate, but not completely because, for example,
if someone was hired on 8/24/09 and today's date is 5/27/10, it says that
person has worked here for a year (the value result = 1). But because it
technically hasn't been a full year, the number isn't accurate. I would like
for it to return a value = 0 (zero) if it hasn't been a full year between the
two dates.

Is there something I can add to this formula to get an accurate year
difference?

Regards,
allenjc11
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      27th May 2010
It's the same principle as calculating a person's age. Check
http://www.mvps.org/access/datetime/date0001.htm at "The Access Web".

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
Co-author: Access 2010 Solutions, published by Wiley
(no e-mails, please!)

"allenjc11" <(E-Mail Removed)> wrote in message
news:B61935E5-B922-4552-B334-(E-Mail Removed)...
> Hello,
>
> I have the following formula in Access 2007 to determine how many years
> someone has been with the company.
>
> -----
>
> Years of Service: DateDiff("yyyy",[Hire Date],[TodaysDate])
>
> -----
>
> This formula is partially accurate, but not completely because, for
> example,
> if someone was hired on 8/24/09 and today's date is 5/27/10, it says that
> person has worked here for a year (the value result = 1). But because it
> technically hasn't been a full year, the number isn't accurate. I would
> like
> for it to return a value = 0 (zero) if it hasn't been a full year between
> the
> two dates.
>
> Is there something I can add to this formula to get an accurate year
> difference?
>
> Regards,
> allenjc11



 
Reply With Quote
 
Dorian
Guest
Posts: n/a
 
      27th May 2010
Look in Access HELP for full details on DateDiff statement.
How about figuring the difference in days and then looking for 365. Of couse
that will not take into account leap years.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"allenjc11" wrote:

> Hello,
>
> I have the following formula in Access 2007 to determine how many years
> someone has been with the company.
>
> -----
>
> Years of Service: DateDiff("yyyy",[Hire Date],[TodaysDate])
>
> -----
>
> This formula is partially accurate, but not completely because, for example,
> if someone was hired on 8/24/09 and today's date is 5/27/10, it says that
> person has worked here for a year (the value result = 1). But because it
> technically hasn't been a full year, the number isn't accurate. I would like
> for it to return a value = 0 (zero) if it hasn't been a full year between the
> two dates.
>
> Is there something I can add to this formula to get an accurate year
> difference?
>
> Regards,
> allenjc11

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      28th May 2010
On Thu, 27 May 2010 12:53:29 -0700, allenjc11
<(E-Mail Removed)> wrote:

>Hello,
>
>I have the following formula in Access 2007 to determine how many years
>someone has been with the company.
>
>-----
>
>Years of Service: DateDiff("yyyy",[Hire Date],[TodaysDate])
>
>-----
>
>This formula is partially accurate, but not completely because, for example,
>if someone was hired on 8/24/09 and today's date is 5/27/10, it says that
>person has worked here for a year (the value result = 1). But because it
>technically hasn't been a full year, the number isn't accurate. I would like
>for it to return a value = 0 (zero) if it hasn't been a full year between the
>two dates.
>
>Is there something I can add to this formula to get an accurate year
>difference?


One way:

Years of Service: DateDiff("yyyy",[Hire Date],[TodaysDate]) - IIF(Format([Hire
Date], "mmdd") > Format([TodaysDate], "mmdd"), 1, 0)

You can of course use the builtin Date() function in place of [TodaysDate] if
you really want the current date.
--

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
calc. an anniversary date(50 years) after marriage date in excel datakop Microsoft Excel Worksheet Functions 3 4th Jan 2010 11:03 PM
how to write; specific date minus date of birth equals years =?Utf-8?B?anVzdCBhbm90aGVyIE1pa2U=?= Microsoft Access Queries 7 18th Mar 2006 03:56 AM
calculate no. of years between a date and today's date =?Utf-8?B?U3Vl?= Microsoft Excel Worksheet Functions 10 14th Jun 2005 02:56 AM
calculate date differences in years and months =?Utf-8?B?Sm95Y2U=?= Microsoft Excel Worksheet Functions 1 14th Mar 2005 05:18 PM
Date sent items are 2 years earlier to the system date Stef Microsoft Outlook 0 24th Jun 2004 07:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:16 AM.