PDA

View Full Version : Saving date in CSV file



Jeevie
12-28-2012, 08:51 AM
Hi All

Is there a way to save date in yyyy-mm-dd hh:mm format in a CSV file without changing the regional settings. I have another system that accepts data uploads with date in yyyy-mm-dd hh:mm format and hence the question.

Thanks in advance and very Happy New Year to all !

GarysStudent
12-28-2012, 09:48 AM
How about:

Sub Macro1()
Range("A1").Formula = "=text(now(),""yyyy-mm-dd hh:mm"")"
ActiveWorkbook.SaveAs Filename:="C:\Users\James\Desktop\Book1.csv", _
FileFormat:=xlCSV, CreateBackup:=False
End Sub

Jeevie
12-29-2012, 03:00 AM
Thanks for your reply. But when the file is reopened, the date format changes to mm/dd/yyyy hh:mm. Is it possible to even store the format as text?