Reputation: 143
I am pulling in all the records from my customer database(mysql) for the last ten days
$offset1 =strtotime("-10 day");
$date3=date("Y-m-d",$offset1);
SELECT * FROM customers WHERE date between '$date3' and '$date' AND customer.custid = '$custid' ORDER by date DESC
I would like to leave out the dates falling on a saturday or sunday and would like to put this in my query rather than the php
If you can help thanks
Upvotes: 1
Views: 3170
Reputation: 102378
I think you can use the DAYNAME function:
AND DAYNAME(date) NOT IN ('Saturday', 'Sunday')
Upvotes: 2
Reputation: 39325
You can use the DayOfWeek
function from MySQL.
SELECT *
FROM customers
WHERE date between '$date3' and '$date'
AND DayOfWeek(date) <> 1
AND DayOfWeek(date) <> 7
AND customer.custid = '$custid'
ORDER by date DESC
Upvotes: 4