M
M
Mikhail Aksenov2020-03-05 17:42:09
Standardization
Mikhail Aksenov, 2020-03-05 17:42:09

How to convert integer to time value?

There is a task to receive contents of certain tables from ERP Galaktika installed on MS SQL.
The table has a field containing the time, in the database it looks like just an integer of 9 digits.
For example: [251865884, 238621261, 268574281]
In the Galaxy, these numbers turn into [15:03, 14:57, 16:02]

Maybe someone has come across similar options for storing time, especially in older systems? What operations need to be performed on numbers to turn them into time?

UPD: The date field also consists of an integer of 9 digits. It can be converted to a date with the following operations:

year = number / 2^16
month = number / 2^8 mod 2^8
date = number mod 2^8

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hint000, 2020-03-05
@uberpwnr

Empirically: (number of seconds from midnight)*4648.5
i.e. divide the integer by 4648.5, convert the result from seconds to hours and minutes (divide by 60 and again by 60, take the integer part and the remainder of the division)
True, 14:57 is noticeably knocked out, maybe you have a typo?

Update:

hours = number / 2^24
minutes = (number mod 2^24) / 2^16

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question