Date Calculation showing years and months (1 Viewer)

karatelung

Registered User.
Local time
Today, 18:51
Joined
Apr 5, 2001
Messages
84
I currently use this as my Control Source for an unbound text box to show the no. of years a client has been licensed:

=DateDiff("yyyy",[LicenseDate],Now())+Int(Format(Now(),"mmdd")<Format([licensedate],"mmdd"))

When a client has been licensed for less than 1 year, it shows "0". How can I get my text box to show years and months?

Thanks
 

GaryC

Registered User.
Local time
Today, 23:51
Joined
Apr 25, 2001
Messages
31
Try

= DateDiff("yyyy", [LicenceDate], Now()) & " Yrs - " & DateDiff("m", [LicenceDate], Now()) - 12 * (DateDiff("yyyy", [LicenceDate], Now())) & " Mths"
 

karatelung

Registered User.
Local time
Today, 18:51
Joined
Apr 5, 2001
Messages
84
Thanks, GaryC, you got me thinking in the right direction, but I had to make some adjustments.

Here is my final code for displaying a difference in the current date and an entered date that displays years and months in the same unbound text box:

=DateDiff("yyyy",[LicenseDate],Now()) & " years and " & DateDiff("m",[LicenseDate],Now())-(DateDiff("yyyy",[LicenseDate],Now())+Int(Format(Now(),"mmdd")<Format([licensedate],"mmdd")))*12 & " months"

Hope someone else can use this. If you're new to this, [LicenseDate] is the only thing that you'll have to change to get this to work for you.

Richie
 

Users who are viewing this thread

Top Bottom