Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Alpha date converted to numeral date
Message
De
21/03/2001 19:56:03
 
 
À
21/03/2001 00:32:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00485959
Message ID:
00487475
Vues:
13
The real savings come from the elimination of the transform() calls, the elimination of the string concatination, and the elimination of the string parsing by ctod(). Additionally, the use of date() instead of ctod() eliminates any problems with set date.


>Hi Albert,
>
>I'm sure it does. I just have an aversion to massively large single line functions. Hard to debug at times :-)
>
>>this runs in 1/3 the time:
>>
>>
>>function strtodate (cLongDate)
>>	return date( val(substr(cLongDate, at(",", cLongDate) + 1)), ;
>> 		(AT(UPPER(LEFT(ltrim(cLongDate), 3)), "   JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC") - 1) / 3, ;
>> 		VAL(SUBSTR(cLongDate, AT(" ", cLongDate) + 1, 2)))
>>endfunc
>>
>>
>>
>>>Hey Jim,
>>>
>>>This'll do it.
>>>
>>>LPARAMETERS cLongDate
>>>nStrictdate=SET("STRICTDATE")
>>>cDate=RIGHT(cLongDate,4)
>>>cMonths="   JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"
>>>cMonthNum=TRANSFORM((AT(UPPER(LEFT(cLongDate,3)),cMonths)-1)/3)
>>>cDayNum=TRANSFORM(VAL(SUBSTR(cLongDate,AT(" ",cLongDate)+1,2)))
>>>cDate=cMonthNum+"/"+cDayNum+"/"+cDate
>>>dDate=CTOD(cDate)
>>>SET STRICTDATE TO nStrictdate
>>>RETURN dDate
>>>
>>>Use as dMyDate=CVRTDATE("Sept 9,1999")
>>>
>>>>I once used a function or precedure I thought I downloaded from the knowledge base that I can't seem to find now. This code took a spelled out date like, Sept 3, 1999, and converted to a numeral date of 09/03/1999. Would someone know what that article number was on Knowledge base, or have the actual code that would convert the date type?
>>>>
>>>>TIA
>>>>
>>>>Jim
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform