How to convert string data into datetime in SQL Server using dateadd() function -


this "1432443679" string stored in column called due_date. need convert datetime using dateadd function below formula.

when applied in excel workbook datetime "5/24/2015 5:01:19". in sql server couldn't time , date part.

  • formula: 1970/01/01 12:00:00 + (1432443679/86400)
  • excel worksheet result 5/24/2015 5:01:19

please assist me

thanks in advance.

try this

select dateadd(ss,1432443679,cast('1970-01-01' datetime)) 

no need convert seconds number of days dividing 86400. in dateadd() function use seconds datepart directly add seconds 1970-01-01 , date.

select dateadd(ss,cast(due_date bigint),cast('1970-01-01' datetime)) tablename 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -