MySQL查询不含周末的五天前的日期

来源:http://database.ctocio.com.cn/askexperts/216/7618716.shtml?ticket=ST-1398-lQWKhI5ZqQLqVscF67h8

select distinct
       cust.fname
     , cust.lname
     , cust.phone
  from orders as o
inner
  join customers as cust
    on cust.id = orders.cust_id
 where o.date_ordered =
       date_sub( current_date
               , interval
       7 - 2 * floor(dayofweek(current_date)/7)
         + floor((dayofweek(current_date)-2)/7)
                     day )
   and o.date_shipped is null

你可能感兴趣的:(MySQL查询不含周末的五天前的日期)