TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

SQLite now

SQLite now with history, features, advantages, installation, commands, syntax, datatypes, operators, expressions, databases, table, crud operations, clauses, like, glob, limit, and clause, advance sqlite

<< Back to SQLITE

SQLite now Function

SQLite "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:

Index format Explanation
1) %Y Year as 4 digits (0000 to 9999)
2) %W Week of year (00 to 53)
3) %w Day of week (0 to 6, where 0 is Sunday)
4) %m Month of year (01 to 12)
5) %d Day of month (00 to 31)
6) %H Hour (00 to 24)
7) %M Minute (00 to 25)
8) %S Seconds (00 to 59)
9) %s Seconds since 1970-01-01
10) %f Fractional seconds (SS.SSS)
11) %j Day of year (001 to 366)
12) %J Julian day as a numeric value

Example: Retrieve current date:

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

Output:

SQLite Now function 1 SQLite Now function 2

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:

SQLite Now function 3 SQLite Now function 4 SQLite Now function 5 SQLite Now function 6
Next TopicSQLite Strftime




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf