Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Answer: Best Way to Find Last Day of Month
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00041995
Message ID:
00042696
Views:
53
>>A thread a while ago was discussing the best way to find the last day of the current month. Since I couldn't find the messages I'll go ahead and answer the question here. The following code will find the last day of the month when passed a date parameter:
>>
>>Procedure LastDay
>>LPARAMETERS dCurrent
>>
>>LOCAL lcValue, lcMonth, lcYear, ldValue, ldNewDate
>>
>>ldValue = GOMONTH(dCurrent,1)
>>lcMonth = STR(MONTH(ldValue))
>>lcYear = STR(YEAR(ldValue)
>>lcValue = lcMonth+"/"+"01"+"/"+lcYear
>>ldNewDate = CTOD(lcValue) - 1
>>
>>Return ldNewDate
>Michael,
>
>The answer that we found was;
>
> LPARAMETERS pDDate
> RETURN GOMONTH(pdDate,1) - DAY(GOMONTH(pdDate,1))
>
>It is less code I know but it works <g>.

This (Jim's) is also the method given in the August FoxTalk issue and works regardless of the user's set('date'). Might this now be accepted as the "definitive" answer? Good enough for a FAQ considering the amount of discussion it has received?
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform