sql date sqlite code example

Example: sqlite datetime

-- SQLite -- 
-- Every database system has it's own set of 
-- functions specifically tasked for handling dates and times. 
-- These functions are not standardized.
-- Date and time related functions for SQLite

SELECT DATETIME('now'); --> Result UTC Time: 2020-11-24 11:31:02
SELECT DATE('now'); --> Result: 2020-11-24
SELECT DATETIME('now', '+1 day'); --> Result UTC Time: 2020-11-25 11:34:56
SELECT DATETIME('now', '+3 day'); --> Result UTC Time: 2020-11-27 11:35:30 
SELECT DATETIME('now', '-1 month'); --> Result UTC Time: 2020-10-24 11:35:57
SELECT DATETIME('now', '+1 year'); --> Result UTC Time: 2021-11-24 11:36:29
SELECT DATETIME(
  'now', 
  '+3 hours', 
  '+27 minutes', 
  '-1 day', 
  '+5 years')
; --> Result UTC Time: 2025-11-23 15:08:55

Tags:

Sql Example