1

I have a column in startTime in my table which is an epoch time. I want to impose date between condition for give date.

SELECT 
    *, DATEADD(SECOND,startTime,'1970-01-01') 
FROM 
    [dbo].[State] 
WHERE
    startTime BETWEEN DATEDIFF(s,'19700101 05:00:00:000','12-01-2015') 
                  AND DATEDIFF(s,'19700101 05:00:00:000','13-01-2015')

Here startTime is unix time column

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
vkrams
  • 7,267
  • 17
  • 79
  • 129

1 Answers1

0

have a conversion function that converts from unix time to datetime this answer has such a function How can I convert bigint (UNIX timestamp) to datetime in SQL Server?

declare @startdate datetime ='2015-01-12'
declare @enddate datetime ='2015-01-13'


select *
from state
where fn_ConvertToDateTime(startTime) between @startdate and @enddate
Community
  • 1
  • 1
radar
  • 13,270
  • 2
  • 25
  • 33