Getting day, month, year information from epoch time in SQLite

Viewed 19

My database stores date in epoch time. I am trying to extract the day,month,year information from this epoch time. I came up with a solution as follows by first converting the epoch time into string date then using strftime, however runtime is a concern as this method is kind of redundant as for each operation I have to convert to epoch into date.I am using sqlite in R so please ignore the dbGetQuery command.

dbGetQuery(db,"SELECT strftime('%d', datetime(started_at, 'unixepoch', 'localtime')),
       strftime('%m', datetime(started_at, 'unixepoch', 'localtime')),
       strftime('%Y', datetime(started_at, 'unixepoch', 'localtime')) FROM mytable")

What are some more optimized ways of extracting this info from epoch time?

0 Answers
Related