Skip to content

Instantly share code, notes, and snippets.

@ValchanOficial
Created December 24, 2019 13:22
Show Gist options
  • Select an option

  • Save ValchanOficial/82c4fb2d6e9806a8dfb8c61f2440a6cc to your computer and use it in GitHub Desktop.

Select an option

Save ValchanOficial/82c4fb2d6e9806a8dfb8c61f2440a6cc to your computer and use it in GitHub Desktop.

Revisions

  1. ValchanOficial created this gist Dec 24, 2019.
    37 changes: 37 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    https://stackoverflow.com/a/1888569/11842937

    In MySQL:

    SELECT *
    FROM mytable
    WHERE record_date >= NOW() - INTERVAL 1 DAY
    In SQL Server:

    SELECT *
    FROM mytable
    WHERE record_date >= DATEADD(day, -1, GETDATE())
    In Oracle:

    SELECT *
    FROM mytable
    WHERE record_date >= SYSDATE - 1
    In PostgreSQL:

    SELECT *
    FROM mytable
    WHERE record_date >= NOW() - '1 day'::INTERVAL
    In Redshift:

    SELECT *
    FROM mytable
    WHERE record_date >= GETDATE() - '1 day'::INTERVAL
    In SQLite:

    SELECT *
    FROM mytable
    WHERE record_date >= datetime('now','-1 day')
    In MS Access:

    SELECT *
    FROM mytable
    WHERE record_date >= (Now - 1)