Osanda Malith
Osanda Malith

Reputation: 47

SQLite Format Seconds

Suppose there is a value 20 which is in seconds in the table. I want to return 20 in the format: 00:00:20

Also if there is 120 seconds it should return in the format: 00:02:00

I tried using datetime, time, strftime functions, but still did not get it right.

Can anyone give me a query to perform this in SQLite3?

Upvotes: 0

Views: 82

Answers (1)

CL.
CL.

Reputation: 180020

One of the supported date/time formats is a number of seconds, so you just have to tell the date/time functions to interpret the number of seconds in that format by using the unixepoch modifier:

> SELECT time(120, 'unixepoch');
00:02:00

Upvotes: 2

Related Questions