Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date Format Conversion
Message
From
13/06/2003 10:44:35
Jeffrey Havelock
Skipton Information Group
Leeds, United Kingdom
 
 
To
13/06/2003 10:36:14
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00799768
Message ID:
00799786
Views:
21
Thanks for this - this is certainly more space conservative than my solution which adds a new column to hold reformatted results, followed by ...

REPLACE ALL NewDateField WITH CTOD(LEFT(CDateField,2)+"/"+ ;
IIF(SUBSTR(CDateField,4,3)="Jan", "01", ;
IIF(SUBSTR(CDateField,4,3)="Feb", "02", ;
IIF(SUBSTR(CDateField,4,3)="Mar", "03", ;
IIF(SUBSTR(CDateField,4,3)="Apr", "04", ;
IIF(SUBSTR(CDateField,4,3)="May", "05", ;
IIF(SUBSTR(CDateField,4,3)="Jun", "06", ;
IIF(SUBSTR(CDateField,4,3)="Jul", "07", ;
IIF(SUBSTR(CDateField,4,3)="Aug", "08", ;
IIF(SUBSTR(CDateField,4,3)="Sep", "09", ;
IIF(SUBSTR(CDateField,4,3)="Oct", "10", ;
IIF(SUBSTR(CDateField,4,3)="Nov", "11", "12")))))))))))+"/"+ ;
SUBSTR(CDateField,8,2))

Thanks for your help.

Jeff


>I have a character field containing dates in format "DD-MON-YY", i.e. "12-Jan-03".
>
>Has anyone got an easy answer to indexing this field in date order of year-month-day. Is there a function to convert i.e "Jan" to "01", "Feb" to "02" etc.?
>
>Regards
>
>Jeff

I don't think VFP has such a function built-in, but it is fairly easy to create a UDF, for instance:


function DateNameToNumber(tcMonth)
tcMonth = upper(tcMonth)
do case
case tcMonth = "JAN"
return "01"
case tcMonth = "FEB"
return "02"
...
case tcMonth = "DEC"
return "12"
otherwise
return "00"
endcase
Jeff Havelock
Senior Data Developer
jeff.havelock@eurodirect.co.uk
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform