Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help importing date into Excel file

Status
Not open for further replies.

Griffinator

Programmer
Dec 30, 2002
28
0
0
CA
I have a problem that I hope someone can help me with.

I am exporting a CSV file into an Excel spreadsheet, and I am having problems importing the date for the current entry in the CSV file. The date in the CSV file is in yyyy-mm-dd h:mm:ss tt format (where tt is either AM or PM).

The problem is that I cannot figure out how to make the date display in the Excel sheet in the same format that it displays in the CSV file. I have managed to format and display it so it shows the yyyy-mm-dd h:mm:ss part, but the AM or PM part will not show.

Any help would be appreciated. Thanks in advance!
 
I have "sort of" solved my own problem. The format is as follows:

objExcel.Application.Cells(i, 1).Value = Format(strExportDate, "yyyy-mm-dd h:mm:ss:ampm")

However, this will produce the following output:
2003-12-27 10:00:00:pM

Is there another way to do this so that there is no colon between the seconds and the PM?

Thanks in advance!

 
Have you tried:

objExcel.Application.Cells(i, 1).Value = Format(strExportDate, "yyyy-mm-dd h:mm:ss am/pm")

-Sean
 
Hi SeanGriffin,

I tried as you suggested. Unfortunately when I do this it creates a format of 12/24/03 10:00. It completely truncates the seconds, as well as the AM/PM part.

However, when I select any one of the date cells within the Excel spreadsheet, the value displayed in the current cell value bar (sorry for the terminology, not sure what to call it) displays the entire date including the AM or PM part. So I am not sure if it is just a matter of Excel truncating the data so it can display in the Date column or what it is. It doesn't matter how much I "stretch" out the column, it will not display the entire date.

As it turns out, after discussing this with the end user it is not necessary to display the AM/PM part. However, if anyone has another idea how to do this (in case I come up against this again), your input would be greatly appreciated.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top