Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting string date to numeric
Message
De
22/03/2003 09:38:56
Fabian Belo
Independent Developer
Argentine
 
 
À
22/03/2003 05:50:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00768883
Message ID:
00768904
Vues:
15
Steven;

Actually is impossible to return a numeric value if you need ‘/’ separators.
To get a string like this: 21/01/2003
SET century on
cDate = "21 January 2003"
cRes = left(cDate,2)+"/"+_Month(substr(cDate,4,len(cDate)-8))+"/"+right(cDate,4)
? cRes
_Month function is needed:
FUNCTION _Month(cMes)
	LOCAL cOut
	DO CASE
		CASE cMes = "January"
			cOut = "01"
		CASE cMes = "February"
			cOut = "02"
		CASE cMes = "March"
			cOut = "03"
		CASE cMes = "April"
			cOut = "04"
		CASE cMes = "May"
			cOut = "05"
		CASE cMes = "June"
			cOut = "06"
		CASE cMes = "July"
			cOut = "07"
		CASE cMes = "August"
			cOut = "08"
		CASE cMes = "September"
			cOut = "09"
		CASE cMes = "October"
			cOut = "10"
		CASE cMes = "November"
			cOut = "11"
		CASE cMes = "December"
			cOut = "12"
	ENDCASE
	RETURN cOut
ENDFUNC
Maybe there's a shorter way (no function at all), but this is all I can do on a Sat. morning....



>Hi everyone,
>
>Could anyone tell me how to change a string value of a date (e.g. 21 January 2003) to a numeric value (e.g. 21/01/2003)with some basic syntax ?
>
>Regards,
>
>Steve.
"Since I've read that alcohol is bad... I quit reading."
Me


http://www.fabianbelo.com.ar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform