Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

how to convert datetime excel sheet to sqlserver datetime Expand / Collapse
Author
Message
Posted Saturday, December 05, 2009 12:24 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, July 15, 2011 7:08 AM
Points: 32, Visits: 58
I want o import excel sheet which have a datetime columns such as Date of Birth into sql server datetime,but problem is that in the excel sheet datetime format is "dd-mm-yyyy" and the sql server appends "MM/dd/yyyy".how can i import this column.
Post #829363
Posted Saturday, December 05, 2009 12:39 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, February 21, 2014 2:16 PM
Points: 1,259, Visits: 3,417
When you import data from Excel using wizard, the column with Date will appear in this format
yyyy-mm-dd hh:nn:ss.mss

so you can now select the imported table with formatting date convert(nvarchar, date_column, 105)

The script will look like this:

  SELECT your_columns, CONVERT(NVARCHAR, date_column, 105) AS your_format
FROM imported_table



============================================================
SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #829364
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse