Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date Format Conversion
Message
De
13/06/2003 10:55:23
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
13/06/2003 10:44:35
Jeffrey Havelock
Skipton Information Group
Leeds, Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00799768
Message ID:
00799799
Vues:
21
The < PRE > and < /PRE > codes, which you apparently eliminated in your reply, help make computer code more readable: fixed-width font, spaces are maintained, word-wrap is turned off.

>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
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform