Chuck
Chuck

Reputation: 1305

how to do sec_to_time in SQLite?

I have a field with seconds after midnight, and I have to convert it to HH:MM:SS. MySQL has sec_to_time(), which would be perfect, but SQLite does not.

How to convert?

I feel like it's some combination of strftime or date, and some dividing by 3600, but I can't get it.

For example, I need to convert 3601 to 1:01. Or, 32405 -> 9:05.

Upvotes: 0

Views: 554

Answers (1)

forpas
forpas

Reputation: 164214

Use time()

select time(3601, 'unixepoch');

will give:

01:00:01

Upvotes: 2

Related Questions