How to Get the Current Date/Time in SQLite?

Find out how to get the current date/time in SQLite

In SQLite, you can use the string "now" with the datetime(), date(), time() and strftime() functions to get the current date and time. The strftime() function allows the flexibility of specifying the format for the resulting date/time string whereas the other date/time functions simply return the string in the standard formatting. For example:

Get Current Date and Time

To get the current date and time in the "YYYY-MM-DD HH:MM:SS" format, you can do either of the following:

SELECT datetime('now');
SELECT strftime('%Y-%m-%d %H:%M:%S', 'now');

Get Current Date

To get the current date only (in the "YYYY-MM-DD" format), you can do either of the following:

SELECT date('now');
SELECT strftime('%Y-%m-%d', 'now');

Get Current Time

To get the current time only (in the "HH:MM:SS" format), you can do either of the following:

SELECT time('now');
SELECT strftime('%H:%M:%S', 'now');

Hope you found this post useful. It was published . Please show your love and support by sharing this post.