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"