SQLite NOW() Function
In SQLite, there is no now() function, but rather "now" is a time-value parameter that is used in various SQLite functions to retrieve the current date and time. The syntax below shows how to use the "now" parameter with various functions.
Syntax
/* using with DATE() function */ DATE('now'); /* using with TIME() function */ TIME('now'); /* using with DATETIME() function */ DATETIME('now'); /* using with STRFTIME() function */ STRFTIME(format, 'now')
Parameters
format |
|
Example: Current date
In the example below, the SQLite 'now' time-value is used to get the current date.
SELECT DATE('now'); Result: '2022-04-12' SELECT STRFTIME('%Y-%m-%d', 'now'); Result: '2022-04-12'
Example: Current time
Similarly, it can be used to get the current time.
SELECT TIME('now'); Result: '06:08:59' SELECT STRFTIME('%H-%M-%S', 'now'); Result: '06-08-59' SELECT STRFTIME('%H-%M-%f', 'now'); Result: '06-08-59.187' SELECT STRFTIME('%H-%M', 'now'); Result: '06-08'
Example: Current date and time
It can also be used to get the current date and time as shown below:
SELECT DATETIME('now'); Result: '2022-04-12 06:08:59' SELECT STRFTIME('%Y-%m-%d %H-%M', 'now'); Result: '2022-04-12 06-08' SELECT STRFTIME('%Y-%m-%d %H-%M-%S', 'now'); Result: '2022-04-12 06-08-59' SELECT STRFTIME('%Y-%m-%d %H-%M-%f', 'now'); Result: '2022-04-12 06-08-59.187'
❮ SQLite Functions