Last business day before a reference date

from the Artful Common Queries page


Given a date value in datetimecol ...
SELECT 
  @refday := datetimecol,
  @dow := DAYOFWEEK(@refday) AS DOW,
  @subtract := IF( @dow = 1, 2, IF( @dow = 2, 3, 1 )) AS MINUS, 
  @refday - INTERVAL @subtract DAY AS LastBizDay
FROM ... etc

Last updated 22 May 2009




Return to the Artful Common Queries page