Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Function to get the last day of month
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00039619
Message ID:
00040211
Vues:
38
>>>>Yours will not work with a few dates...for example try August 31st. It will return August 30th.
>>>>
>>>>Needs to be in two steps with the second step using the next month's day.
>>>>
>>>>Take care,
>>>>Joe
>>>Joe,
>>>
>>>Right you are, here;s my revised code that doesn't break for August.
>>>
>>>ldDate = {08/01/97}
>>>? (GoMonth(ldDate,1)-day(gomonth(ldDate,1)-1)-1) && returns 08/31/97
>>
>>Actually, your old formula worked fine. The new one doesn't. (It returns 07/31/97).
>
>Haven't followed the thread all the way, but what about doing it this way:
>
>* To find last day in a month out from a date
>lddate = CTOD("08/01/97")
>ldlastday = CTOD(STR(MONTH(lddate)+1)+"/01/"+STR(YEAR(lddate)))-1
>
>Works fine for me. :)

Well. I better correct myself.

ldlastday = CTOD(IIF(MONTH(lddate)=12, "01", STR(MONTH(lddate)+1))+"/01/"+ ;
IIF(MONTH(lddate)=12, STR(YEAR(lddate)+1), STR(YEAR(lddate))))-1


Hate when I do stuff like that from my head, and then go look at my code
afterward, just to find my mistakes. :/


Erik Niese-Petersen
- Erik Niese-Petersen

Crazy Dane in USA.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform