Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Convert Time

Author  Topic 

Mallen
Starting Member

27 Posts

Posted - 2010-10-13 : 12:56:25
I am importing a .csv file and then formatting and cleaning the data to export to a new .csv file for processing.

The date and time that I get in are in this format:
,2010/10/12, 09:14:24,

The format I need to export them in is:
,10/12/2010 9:14:24 AM,

The abbreviated version of the code I am trying is:
INSERT INTO Five9Exp
SELECT
(CONVERT(varchar(10),f.Date,101)+' '+f.Time)
FROM Five9CSV f;

This only outputs the original format and is ignoring the convert date part. (2010/10/12 09:14:24)

Can I change the data while it is in the Five9CSV table or is there some better way to export it in the correct format to the Five9Exp table?

Mallen
Starting Member

27 Posts

Posted - 2010-10-13 : 13:02:13
It also just occurred to me that I am not bulk inserting the data into the Five9CSV table as a date.
Here is my Five9CSV table:

CREATE TABLE Five9CSV
(Date varchar (50),
[Time] varchar (50))

I changed the Date to a datetime and now it is exporting:
10/12/2010 09:14:24

But I can't find a way to convert the time now.
Go to Top of Page
   

- Advertisement -