A SQL "select where date" example

Here's a quick "SQL select where date" example, showing how to select all orders from an example orders table where the order_date is greater than a date we specify.

The SQL "select where date" example

With these assumptions:

  • You have a database table named orders
  • This table has two fields named order_id and order_date

This SQL will give you information about orders placed in the last two days with PostreSQL:

  SELECT order_id,order_date 
  FROM orders 
  WHERE order_date>(CURRENT_DATE-2);

Of course you can use other equality operators to change the meaning of the date comparison.