24

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!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Kristoffer Ahl
  • 1,661
  • 2
  • 18
  • 36

2 Answers2

45

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?

Adriaan Stander
  • 162,879
  • 31
  • 289
  • 284
  • 1
    SQLite appears to lose the time portion of the column values, if there is any. SQL Server would have kept those for a DATETIME or SMALLDATETIME type. Just an observation. – Magnus Smith Nov 02 '15 at 12:27
  • SELECT date('2019-12-17 14:19:19','+14 day'); would lose the time part. – Zhang Dec 17 '19 at 06:19
  • 1
    @MagnusSmith, datetime(timestring, modifier, modifier, ...) would be fine. – Zhang Dec 17 '19 at 06:21
5

The method Adriaan Stander gives result in GMT

You can do it in LocalTime like this

select DateTime('Now', 'LocalTime', '+1 Day');
Abdul Saleem
  • 10,098
  • 5
  • 45
  • 45