Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculating Years and Days
Message
 
To
21/05/2013 03:17:15
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01574342
Message ID:
01574354
Views:
51
>Sir,
>Not working properly, If comm_date is 19/10/2011 and cur_date is 31/03/2013.
>It should be 1 Year and 165 Days (13+30+31+31+29+31).
>
>Knidly Help

Am I correct in assuming that if comm_date is 19/10/2010 and cur_date is 31/03/2012. It should be 1 Year and 164 Days? (13+30+31+31+28+31)

If so, please try:
CLEAR
ldDate1 = DATE(2011,10,19)
ldDate2 = DATE(2013, 3, 31)

lnYears = YEAR(ldDate2) - YEAR(ldDate1)
IF MONTH(ldDate2) < MONTH(ldDate1) OR ;
   ((MONTH(ldDate2) = MONTH(ldDate1)) AND (DAY(ldDate2) < DAY(ldDate1)))
   lnYears = lnYears - 1
ENDIF

ldDate3 = GOMONTH(ldDate2, -12 * lnYears)

lnDays  = ldDate3 - ldDate1 + 1
? "Y:", lnYears,"D:",lnDays
Frank Camp
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform