TheDeveloperBlog.com

Home | Contact Us

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

SQLite datetime

SQLite DateTime 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 datetime Function

The SQLite datetime function is used to retrieve date and time in different format. The result format of datetime function is 'YYYY-MM-DD HH:MM:SS'.

Syntax:

datetime(timestring, [ modifier1, modifier2, ... modifier_n ] ) 

Example1: Retrieve current date and time:

SELECT datetime('now');

Output:

SQLite Datetime function 1

Example2: Add/ subtract years to current date and time:

SELECT datetime('2017-04-13','+5 years');
SELECT datetime('now','+5 years');

Output:

SQLite Datetime function 2 SQLite Datetime function 3

Example3: Add/ subtract days to current date and time:

SELECT datetime('2017-04-13','+5 days');
SELECT datetime('now','+5 days');
 SELECT datetime('now','-5 days');

Output:

SQLite Datetime function 4 SQLite Datetime function 5 SQLite Datetime function 6

Example4: Add/ subtract hours to current date and time:

SELECT datetime('2017-04-13','+5 hours');
SELECT datetime('now','+5 hours');
 SELECT datetime('now','-5 hours');

Output:

SQLite Datetime function 7 SQLite Datetime function 8 SQLite Datetime function 9

Example5: Add/ subtract minutes to current date and time:

SELECT datetime('now','+150 minutes');
 SELECT datetime('now','-50 minutes');

Output:

SQLite Datetime function 10 SQLite Datetime function 11
Next TopicSQLite Juliandday




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