Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Find last date in a month
Message
 
À
22/01/2007 13:40:03
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01187758
Message ID:
01187771
Vues:
18
>>>Is there a quick way to find the last date in any given month. I need to select records that fall within the selected month and year. I was going to use the between() command but how can you select the last date of a month (28,30,31) without lines of code?
>>
>>? LastDay(DATE())      && Just day
>>? LastDay(DATE(), .t.) && We want DATE
>>
>>
>>FUNCTION LastDay(ldDate, lbDateWant)
>> LOCAL ldLastDay
>> ldLastDay = GOMONT(ldDate,1)-DAY(ldDate)
>>RETURN IIF(lbDateWant, DAY(ldLastDay), ldLastDay)
>>
>
>Doesn't work when your ldDate is January, March, May, August or October 31st, and probably also on last 2-3 days of January, because GoMonth() gives you the last of the next month in such cases.
>
>I'd prefer
>
>
gomonth(date(year(ldDate), month(ldDate), 1),1)-1
>
>i.e. find first of the month, from that the first of the next month, go back one day.


OOOPPPPSSSSS!
HUGE MISTAKE!
I am sorry Jim (Thank you Dragan)
FUNCTION LastDay(ldDate, lbDateWant)
 LOCAL ldLastDay
 LOCAL ldNextMonthDate
 ldNextMonthDate = GOMONT(ldDate,1)
 ldLastDay = ldNextMonthDate-DAY(ldNextMonthDate)
RETURN IIF(lbDateWant, DAY(ldLastDay), ldLastDay)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform