Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite equivalent of SQL Server DateAdd function

Tags:

I need help reproducing the following SQL statement to a statement that SQLite understands.

SELECT * FROM SomeTable WHERE [Date] >= DATEADD(day, -14, GETDATE())

Any help is much appreciated!

like image 335
Kristoffer Ahl Avatar asked Dec 04 '09 08:12

Kristoffer Ahl


2 Answers

From this link

Date And Time Functions

it would seem that you can use something like

date(timestring, modifier, modifier, ...) 

SELECT date('now','+14 day'); 

Does this seem correct to you?

like image 76
Adriaan Stander Avatar answered Sep 19 '22 14:09

Adriaan Stander


The method Adriaan Stander gives result in GMT

You can do it in LocalTime like this

select DateTime('Now', 'LocalTime', '+1 Day');
like image 32
Abdul Saleem Avatar answered Sep 18 '22 14:09

Abdul Saleem