Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Not my date type
Message
De
29/03/2014 13:42:20
 
 
À
29/03/2014 11:58:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01597645
Message ID:
01597658
Vues:
52
>>>Hi All,
>>>
>>>Is there a better, or shall I say more elegant, way of extracting the numeric values from a date-formatted ("03/27/2014") text string than the following:
>>>
>>>lnmon=val(left(alltrim(this.text),2))
>>>lnyear=val(right(alltrim(this.text),4))
>>>lnday=val(substr(alltrim(this.text),4,2))
>>>lddate=date(lnyear,lnmon,lnday)
>>>
>>
>>I'll ask the obvious - have you tried CTOD(this.text)?
>
>
>CTOD() can do it as well but runs a risk of ambiguous date values (see the help). Using the DATE() function is safer because you need to specify the year, month and day specifically.

It appears that the date string is itself non-universal (what the OP showed was US date format).

A more universal approach would be
ln = DBIdatenum && however obtained
ldDate = {^1900/01/01} + ln
Hank
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform