Making Date Field Text

dloskot

New Member
Joined
Oct 18, 2015
Messages
47
I have an interesting issue: I need to create an Excel spreadsheet with data to import to a database.
Some of the fields are dates and they need to be in the format yyyy-mm-dd hh:mm:ss which is easy enough to to do in excel. However database import functions reads it as 4/20/2025 8:15:00 AM. If you save the file as CSV it outputs the date as 4/20/2025 8:15:00 AM.

I have read putting a single quote (') at the beginning of the field will tell excel to treat cell as Text. but if I do that it puts back to 4/20/2025 8:15:00 AM format.
I need to find a way to get these date fields to text fields without having to retype all of them in Text format. I have uploaded a sample.
Date to Text Sample.xlsx
ABC
1locationevent_dateevent_end_date
2KAH Bay Area Warehouse2025-03-18 10:15:002025-03-18 11:45:00
3Greenbrook Elementary School2025-03-20 08:15:002025-03-20 10:30:00
4KAH Bay Area Warehouse2025-03-22 10:00:002025-03-22 11:30:00
Event input to Event Booking
 
If you format the it the way you want in Excel, then the CSV will be created in that EXACT same format.
Just don't make the mistake of trying to view the CSV in Excel - when you do that, Excel will automatically apply its own conversions on the data.
For this reason, whenever you want to truly view the contents of a CSV or any other Text file, NEVER open it in Excel.
Look at it in a Text Editor like NotePad to see what truly is in that file.
 
Upvote 0
Solution
If you format the it the way you want in Excel, then the CSV will be created in that EXACT same format.
Just don't make the mistake of trying to view the CSV in Excel - when you do that, Excel will automatically apply its own conversions on the data.
For this reason, whenever you want to truly view the contents of a CSV or any other Text file, NEVER open it in Excel.
Look at it in a Text Editor like NotePad to see what truly is in that file.
Thanks Joe4: I thought I had tried that and it didn't seam work. I tried it again and it worked as you described.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top