Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert Excel Date Serial Number to Regular Date

I got a column called DateOfBirth in my csv file with Excel Date Serial Number Date

Example:

  36464   37104   35412 

When i formatted cells in excel these are converted as

  36464 => 1/11/1999   37104 => 1/08/2001   35412 => 13/12/1996 

I need to do this transformation in SSIS or in SQL. How can this be achieved?

like image 943
Sreedhar Avatar asked Dec 12 '12 23:12

Sreedhar


People also ask

How do you stop Excel from changing dates to serial numbers?

Add an Apostrophe before the Number If you only have to enter a number in a few cells and you don't want Excel to change it to date, you can use this simple technique. Just add an apostrophe sign before you enter the number (as shown below).

Does Excel use serial numbers for dates?

Excel stores dates as sequential serial numbers so that they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900. Most functions automatically convert date values to serial numbers.


1 Answers

In SQL:

select dateadd(d,36464,'1899-12-30') -- or thanks to rcdmk select CAST(36464 - 2 as SmallDateTime) 

In SSIS, see here

http://msdn.microsoft.com/en-us/library/ms141719.aspx

like image 170
Nick.McDermaid Avatar answered Oct 06 '22 00:10

Nick.McDermaid