Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
SELECT * FROM orders WHERE
  orders.date_created <= $targetDateTime AND
  orders.date_stopped >= $targetDateTime AND
  (order.auto_expire_date IS NOT NULL AND orders.auto_expire_date >= $targetDateTime) AND
  NOT voided;

In the common use case where we are looking for currently active orders (i.e., TARGET DATETIME is now), we can simplify this to:

Code Block
langagesql
SELECT * FROM orders WHERE
  NOT orders.stopped AND
  (orders.auto_expire_date IS NOT NULL AND orders.auto_expire_date >= NOW()) AND
  NOT voided;