469,568 Members | 1,558 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,568 developers. It's quick & easy.

Calculate Year In Service (YIS) in the format of Years and month

I have two dates - Date Joined and Actual Last Day. How do I find the
YIS in for format of Years and Month from these two dates. Eg, Date
Joined: 28/06/1971 and Actual Last Day: 24/01/2007, then the YIS
should shows: 35 yrs 6 mth.

Sep 4 '07 #1
2 4650
On Sep 4, 2:30 am, ic...@scs.com.sg wrote:
I have two dates - Date Joined and Actual Last Day. How do I find the
YIS in for format of Years and Month from these two dates. Eg, Date
Joined: 28/06/1971 and Actual Last Day: 24/01/2007, then the YIS
should shows: 35 yrs 6 mth.
Use DateDiff( ) to get the months and years. For example, if you had
a textbox named txtDate1 and a texbox named txtDate2, and a textbox
named txtYIS, then you could put the following code in the click event
of a command button, or in the AfterUpdate event of some control:

Dim Date1 as Date
Dim Date2 as Date
Dim Years as Integer
Dim Months as Integer

Date1=Cdate(txtDate1)
Date2=Cdate(txtDate2)
Years=DateDiff("YYYY",Date1,Date2)
Months=DateDiff("M",Date1,Date2) - (Years*12)
txtYIS=Format(Years) & " yrs " & format(Months) & " mth"

Sep 4 '07 #2
On Sep 4, 2:30 am, ic...@scs.com.sg wrote:
I have two dates - Date Joined and Actual Last Day. How do I find the
YIS in for format of Years and Month from these two dates. Eg, Date
Joined: 28/06/1971 and Actual Last Day: 24/01/2007, then the YIS
should shows: 35 yrs 6 mth.
In:

http://groups.google.com/group/micro...03152fa335dbe9

I posted a query for elapsed time in years, months and days. It
should work on non-U.S. dates. It seems to give results that match
what I expect. I have not studied OldPro's solution.

James A. Fortune
CD********@FortuneJames.com

Sep 6 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Tencip | last post: by
13 posts views Thread by David Gray | last post: by
26 posts views Thread by Frank | last post: by
4 posts views Thread by Jan Szymczuk | last post: by
6 posts views Thread by charliewest | last post: by
8 posts views Thread by amackeyb | last post: by
37 posts views Thread by mazwolfe | last post: by
9 posts views Thread by Pierre Quentel | last post: by
15 posts views Thread by student4lifer | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.