Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert Text to Date, but conditionally
Message
De
31/08/2008 12:59:33
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
 
 
À
31/08/2008 12:54:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01343648
Message ID:
01343652
Vues:
22
>>
>>cDate = '081308'
>>cTime = '0945'
>>cValue = cDate + cTime
>>
>>dNewDate = CTOT(TRANSFORM(cValue),'@R ^99/99/99T99:99:99'))
>>
>>The Result is a valid DateTime.
>>
>>But what if the cValue is not a valid datetime? I want to be able to do this:
>>
>>IF cValue is a valid datetime
>>	dNewDate = CTOT(TRANSFORM(cValue),'@R ^99/99/99T99:99:99'))
>>ELSE
>>	* This is some other type and I do not want to try and convert it
>>ENDIF
>>
>>This is for a report where cValue can be anything. It is always character, but on the report I want to evaluate it and display a real date if it is a date, but leave it alone if it is not.
>
>
>Get some beer :-)

Too early here!

>
>dNewDate = CTOT(TRANSFORM(cValue),'@R ^99/99/99T99:99:99'))
>IF EMPTY(dNewDate)
>    *** Not a valid date time
>ELSE
>     *** Valid date time
>ENDIF
>
Ok, so...
IIF(EMPTY(CTOT(TRANSFORM(cValue),'@R ^99/99/99T99:99:99'))),cValue,CTOT(TRANSFORM(cValue),'@R ^99/99/99T99:99:99')))
I guess I was trying not to add the conditinal overhead to every value in the detail line in the report, but now that I think about it, there really is no other way.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform