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