Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I get the day?
Message
De
30/05/2014 15:21:00
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
30/05/2014 13:10:49
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows NT
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01600946
Message ID:
01601010
Vues:
60
>>>>>From a digit (1 to 7) how do I get the day? I forgot if there is a native function in Fox to do that.
>>>>>
>>>>>For example
>>>>>
>>>>>GiveMeTheDay( 2) would give a result of "Monday"
>>>>
>>>>Try
>>>>
>>>>FUNCTION cWeekDay
>>>> LPARAMETERS;
>>>>  tnDayNumber
>>>>
>>>> RETURN CDOW(DATE()-DOW(DATE(),0)+tnDayNumber)
>>>>ENDFUNC &&cWeekDay
>>>>
>>>
>>>If you omit the Function wrapper, this is a true one-liner. I like this (and it seems I did write one like that years ago).
>>>
>>>We didn't have a good date challenge here for months. This refreshed my day.
>>
>>If that fires so the first DATE() is before midnight 23:59:59.999 and the second DATE() is on or after midnight - so it is the next day, the result will be wrong.
>
>I'm believe the student can come around this problem as an exercise. :)
>
>The result is wrong anyway. Monday is the first day of the week. Also it will not respond to the language the user set within the prog.
>
>(eg)

Which are extra reasons why you are very correct to make it a UDF. :)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform