By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,224 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,224 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.