0

How to convert a number such as 42161 to a date in MySQL Server?

Appreciate any tips or pointers in the good direction.

I tried this and it doesn't work:

select distinct CONVERT(datetime,[Update date]) from Table1

The error shown is:

Msg 241, Level 16, State 1, Line 1 Conversion failed when converting date and/or time from character string.

I also tried this and it does work:

select distinct CONVERT(datetime,CONVERT(numeric(18,0),[Update date]))
from Table1

Just wondering if it's the proper or best solution. I plan to create a new column that contains the converted values (into datetime format).

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
Samy
  • 465
  • 1
  • 10
  • 25
  • http://stackoverflow.com/questions/13850605/t-sql-to-convert-excel-date-serial-number-to-regular-date – JNevill Jun 16 '15 at 15:54
  • 1
    so... what date is the number 12? Is that December, or the 12th day of June or is it 12 seconds since Unix Epoch? It would help to know what format the number represents before translation. – Martin Jun 16 '15 at 15:56

0 Answers0