Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Not my date type
Message
From
29/03/2014 13:42:20
 
 
To
29/03/2014 11:58:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01597645
Message ID:
01597658
Views:
51
>>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform