Link to home
Start Free TrialLog in
Avatar of Zahid Ahamed
Zahid AhamedFlag for United States of America

asked on

T-SQL query output

Hi,

I would like to get a information for the date 01/18/2018 created UTC column.

Alert me
Question
Vote as helpful
0
Vote
Hi,

I have a table name BtPrintJobs

I have tried the following way,

select top 3 * from BtPrintJobs

results:

CreatedUTC
636482124361400000
636482118335560000
636482118264740000

i ran this following query to get last utc

select MIN(CreatedUTC) from BtPrintJobs

Declare @TickValue bigint
Declare @Days float


Set @TickValue = 635283186097710000
Select @Days = @TickValue * POWER(10.00000000000,-7) / 60 / 60 / 24


Select DATEADD(d, Cast(@Days As int), Cast('0001-01-01' As DATE))
    + Cast( (@Days - FLOOR(@Days)) As DateTime)

where i get the date information 2013-11-07
Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image

And your question is.....?
ASKER CERTIFIED SOLUTION
Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zahid Ahamed

ASKER

User is requesting me to get the data for this 01/18/2018, the table has column which is created UTC, i am not able to convert. Please help
The reverse process calculation is also given at the following location.

https://lazarus987.wordpress.com/2014/07/03/how-to-convert-tick-to-datetime-sql/

Use it to arrive at the ticks value (let say @jan18) and then just say

select * 
from BtPrintJobs
where CreatedUTC > @jan18

Open in new window

thanks for your help