Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CSV and Date Format
Message
De
27/10/2010 01:48:22
 
 
À
26/10/2010 21:08:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01487043
Message ID:
01487068
Vues:
44
>>>I have a cursor with a date field in it. I need to save this cursor as a CSV file so..........
>>>
>>>COPY TO (myFile) CSV
>>>
>>>but........
>>>
>>>the date field is saved as MM/DD/YYYY and the user needs it in DD-MMM-YY format. Is there a reasonably easy way to make this format change???? (I've tried various SET DATE settings but didn't seem to get what I need)
>>>
>>>I haven't yet tried it (task for tommorrow or Thursday) but the next attempt is going to be
>>>
>>>save as XLS
>>>open an instance of Excel
>>>load the file (where it displays as desired)
>>>and then SaveAs CSV from Excel
>>>
>>>Any thoughts on if this should work and/or suggestions for a better approach are appreciated.
>>
>>One way would be to create another C( 9 ) column ( "CharDate" ) in your cursor and populate it from the date field ( "MyDate" ) via a UDF:
>>
>>REPLACE ALL CharDate WITH DD_MMM_YY( MyDate ) IN MyCursor
>>
>>* FUNCTION DD_MMM_YY
>>LPARAMETERS ;
>>	tdDate
>>
>>RETURN ;
>>	PADL( LTRIM( STR( DAY( tdDate ) ) ), 2, "0" ) ;
>>	+ "-" ;
>>	+ SUBSTR( CMONTH( tdDate ), 1, 3 ) ;
>>	+ "-" ;
>>	+ RIGHT( LTRIM( STR( YEAR( tdDate ) ) ), 2 )
>>
>
>Thanks for taking the time to respond.
>
>I had thought about that but, unfortunately, the user has a macro which depends upon certain data being in specific formats and specific columns.

Maybe you could use COPY TO ... FIELDS {FieldList} TYPE CSV to include only the columns you want, in the order you want.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform