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

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

Post by iche » Wed, 05 Sep 2007 16:30:38


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.
 
 
 

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

Post by OldPr » Wed, 05 Sep 2007 23:31:27


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"

 
 
 

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

Post by CDMAPoste » Fri, 07 Sep 2007 11:11:33


In:

http://www.yqcomputer.com/

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
XXXX@XXXXX.COM