C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
SQLite now FunctionSQLite "now" is not actually a fuction, but "now" is a timestring parameter that is used in various SQLite functions to fetch the current date and time. Syntax: There are three types of syntax for now function in SQLite:
date('now')
Or
time('now')
Or
strftime(format, 'now')
i.e.
strftime('%Y-%m-%d','now')
strftime('%Y-%m-%d %H-%M','now')
strftime('%Y-%m-%d %H-%M-%S','now')
The third syntax is used when expressing the current date/time using the strftime function. Here "format" can be anyone of the following:
Example: Retrieve current date:
SELECT date('now');
SELECT strftime('%Y-%m-%d','now');
Output:
Example: Retrieve current time:
SELECT time('now'); (HH-MM-SS Format)
SELECT strftime('%H-%M-%S','now'); (HH-MM-SS Format)
SELECT strftime('%H-%M-%f','now'); (HH-MM-SS.SSS Format)
SELECT strftime('%H-%M','now'); (HH-MM Format)
Output:
Next TopicSQLite Strftime
|