I need the SQLite equivalent of MySQL to work with unix timestamps

I am using unix timestamps with SQLite and store them as integer. My problem is that I am trying to select records to date based on their unix timestamps and I have no idea what functions to use.

This is what I would like to use in MySQL:

where date_format(from_unixtime(COLUMN_DATE), '%Y-%m-%d')= date_format(now(), '%Y-%m-%d')

However, when I try to use these functions, I get errors in the log saying they don't exist for SQLite.

How do I write this for SQLite?

+3


source to share


1 answer


SQLite date and time functions are documented at http://sqlite.org/lang_datefunc.html .

The equivalent of your proposal WHERE

would be



WHERE date(COLUMN_DATE,'unixepoch') = date('now')

      

+8


source







All Articles