Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create Date from Character
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00785368
Message ID:
00785373
Vues:
14
>I am trying to create a date from a character expression. I tried CTOD but I ralized that the date has no slashes in it. I always end up parsing the expression and then adding in the pieces and slashes. Is there an easier way to do this?

Would this help?
*FUNCTION todate
LPARAMETERS  tcDate, tcFormat
LOCAL lcFormat, ldDate, lcDate
ldDate = Null
lcFormat = UPPER(ALLTRIM(tcFormat))
DO CASE
CASE lcFormat = "YYYYMMDD"
	lcDate = tcDate
	ldDate = EVALUATE("{^" + TRANSFORM(lcDate, "@R 9999/99/99") + "}")				
CASE lcFormat = "YYMMDD"
	lcDate = LEFT( STR( YEAR( DATE()),4),2) + tcDate
	ldDate = EVALUATE("{^" + TRANSFORM(lcDate, "@R 9999/99/99") + "}")				
OTHERWISE
ENDCASE
RETURN ldDate
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform