I
I
Ilyas2017-11-23 00:33:07
PHP
Ilyas, 2017-11-23 00:33:07

In what format is it better to store the value in the database?

What is the best way to store time duration in DB?
Well, for example, there is a process and this process has a runtime equal to 10 minutes, in what form is it better to give these 10 minutes to the database? The duration may be a few seconds, or it may be several years.
postgresql database.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2017-11-23
@id2669099

There is an interval data type - use it. As the documentation suggests , its accuracy is up to one microsecond, and the range of values ​​... in general, is enough for you.

C
cicatrix, 2017-11-23
@cicatrix

Maybe I will say sedition, but I would store 2 timestamp (beginning and end). 8 bytes per field, equivalent to one 16-byte Interval (I suspect that it has the same logic in its giblets).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question