Click here to Skip to main content
15,905,781 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hello,

I have a value in bigint and i need to convert it into datetime my value is this "19820201150000" i tried these solutions but not a single solution is working.


SQL
SELECT DATEADD(SECOND, 1218456040709 / 1000, '19691231 20:00')

SELECT DATEADD(SECOND, 19820201150000 / 1000, '19691231 20:00')

select dateadd(hh,-4,dateadd(ss,19820201150000/1000,'1970/01/01 00:00'))

select CONVERT(DATETIME,REPLACE(DATEADD( day, 19820201150000, '12/31/1849'),'12/31/1849',0),101)

select dateadd(ss, 19820201150000/1000, '19691231 20:00')

SELECT DateAdd(ms, 19820201150000 % 1000, DateAdd(SECOND, 19820201150000 /  1000, '1970-01-01T00:00:00.000')) AS ToTheMs,
   DateAdd(SECOND, 19820201150000 /  1000, '1970-01-01T00:00:00.000')  AS ToTheSecond,
   DateAdd(MINUTE, 19820201150000 / 60000, '1970-01-01T00:00:00.000')  AS ToTheSecond
Posted
Updated 9-May-18 5:05am

Check the below url
http://stackoverflow.com/questions/3650320/convert-from-bigint-to-datetime-value
 
Share this answer
 
v4
check this
SQL
DECLARE @di_date BIGINT
SET @di_date=19820201150000

DECLARE @ds_date VARCHAR(20)
SET @ds_date=CONVERT(VARCHAR(20), @di_date )

select
Convert(time,Dateadd(SECOND,
        Right(@ds_date,2)/1,
        Dateadd(MINUTE,
                Right(@ds_date,4)/100,
                Dateadd(hour,
                        Right(@ds_date,6)/10000,
                        '1900-01-01')))) +
convert(datetime,LEFT(@ds_date,8)) as DateConverted


credits http://rdineshkumar.wordpress.com/tag/how-to-convert-yyyymmddhhmmss-to-datetimedatetime-in-sql-server
 
Share this answer
 
Comments
srishti_ 25-Sep-14 4:24am    
Thanks
george4986 25-Sep-14 4:40am    
u r welcome ;-)
plz refer given link for reference.
SQL
First please check with this 1982020115000.  (i removed one zero what you gave in the question because as per my knowledge that value should be 13 digits) now it is working
SELECT DATEADD(SECOND, 1982020115000 / 1000, '19691231 20:00')
 
Share this answer
 
v3
SQL
this is the solution

SELECT DATEADD(S, @your-big-int, '19700101')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900