Is there an easy way to get a list of orders placed in the last 4 days?

By Alvin J. Alexander, devdaily.com

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.

Katz!


devdaily logo