Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Function to convert date to words
Message
De
27/03/2003 12:55:28
 
 
À
27/03/2003 12:48:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00770814
Message ID:
00770856
Vues:
12
>>Are there any VFP functions or 3rd party routines that can convert a date to text. IE 11/23/2002 converts to "23rd day of November, 2002"
>>
>>Thanks for you help
>>Stephen Hunt
>
>alright, here is one which should work, even with the '11' mentioned earlier:

Nope, you're on the right track, but still missed the 12th and 13th. Just add those, too, and it'll work.
>FUNC Date2String
>	LPARA ;
>		LcDate
>	Local ;
>		LcDay, ;
>		LcMonth, ;
>		LcYear
>	
>	LcDay = ALLT(STR(DAY(LcDate)))
>	DO CASE
>		CASE RIGHT(LcDay, 1) = "1" .and. LcDay <> "11"
>			LcDay = LcDay + "st"
		CASE RIGHT(LcDay, 1) = "2" and LcDay <> "12"
>			LcDay = LcDay + "nd"
		CASE RIGHT(LcDay, 1) = "3" and LcDay <> "13"

>			LcDay = LcDay + "rd"
>		OTHERWISE
>			LcDay = LcDay + "th"
>	ENDCASE
>	LcMonth	= CMONTH(LcDate)
>	LcYear	= ALLT(STR(YEAR(LcDate)))
>	RETURN(LcDay + " day of " + LcMonth + ", " + LcYear)
>ENDFUNC
>
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform