Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Years and months between two dates
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00160317
Message ID:
00161949
Views:
22
George,

Here's a pretty simple one;
LPARAMETERS pdDate1, pdDate2
LOCAL ldDate1, ldDate2, ldLastDate, lnYears, lnMOnths, lnDays
ldDate1 = MIN(pdDate1,pdDate2)
ldDate2 = MAX(pdDate1,pdDate2)
lnYears = 0
lnMonths = 0
lnDays = 0

DO WHILE ldDate2 > ldDate1
	ldLastDate = ldDate1
	ldDate1 = GOMONTH(ldDate1,1)
	lnMonths = lnMonths + 1
	IF lnMonths = 12
		lnYears = lnYears + 1
		lnMonths = 0
	ENDIF
ENDDO

lnDays = ldDate2 - ldLastDate

? "Years: "
?? lnYears
?"Months: "
?? lnMonths
? "Days: "
?? lnDays
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform