Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting SHORT dates to date values
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01129663
Message ID:
01129669
Views:
15
This message has been marked as the solution to the initial question of the thread.
>I have a file where the dates are in dd-MMM-yy format. I thought I'd let SET DATE SHORT handle it for me, but no luck - I just got blanks back.
>
>Even more amusingly, while DTOC(DATE()) shows the date the same way it is in the table, CTOD(DTOC(DATE())) fails the same way the table dates do.
>
>Any thoughts on how to get this to work, or am I just going to have to reformat the dates before converting them?
>
>Thanks.
SET DATE SHORT
lcMonths = [JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC]
lcDate   = DTOC(DATE())
lnDay    = VAL(LEFT(lcDate,2))
lnYear   = VAL(RIGHT(lcDate,4)) && Change 4 to 2 if you have only last two digits from the year
lcMonth  = UPPER(SUBSTR(lcDate,4,3))
lnMonth  = INT((ATC(lcMonth,lcMonths)/3))+1
? DATE(lnYear, lnMonth, lnDay)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform