What are the sqlite equivalents of INTERVAL and UTC_TIMESTAMP? For example, imagine you were “porting” the following SQL from MySQL to sqlite:
SELECT mumble
FROM blah
WHERE blah.heart_beat_time > utc_timestamp() - INTERVAL 600 SECOND;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
datetime('now')provides you the current date and time in UTC, so is the SQLite equivalent of MySQL’sUTC_TIMESTAMP().It may also be useful to know that given a date and time string,
datetimecan convert it from localtime into UTC, usingdatetime('2011-09-25 18:18', 'utc').You can also use the
datetime()function to apply modifiers such as ‘+1 day’, ‘start of month’, ‘- 10 years’ and many more.Therefore, your example would look like this in SQLite:
You can find more of the modifiers on the SQLite Date and Time Functions page.