SQL Server Date in INT but it's not epoch time

ep6jt1vc  于 2023-06-21  发布在  其他
关注(0)|答案(1)|浏览(113)

I have '77337' and '4477877' delcared as INT in a client's database in SQL Server. Their app displays the following date and time as 9/24/2012 and 12:26 respectively. How were these computed?

From the database:

From the application:

I tried use epoch time or unix time, but it's a far match

Edited the screenshots for more examples

xmakbtuz

xmakbtuz1#

As mentioned by @zhorov in comments the entrydate values are number of days after 1800-12-28 , so the complete calcul can be :

select *, CONVERT(date, (DATEADD(day, entrydate, '1800-12-28'))) AS DATE,
          FLOOR(entrytime/3600/100) AS HOURS , 
          FLOOR(entrytime/3600%100*60/100) AS MINUTES
from mytable

Result :

entrydateentrytimeDATEHOURSMINUTES
7733744778772012-09-241225
7741831357042012-12-14842

Demo here

相关问题