I’m trying to make a change this part of the sql
(To_days( now( )) - TO_DAYS( o.date_payed)) days1,
(To_days( now( )) - TO_DAYS( o.date_purchased)) days2,
This works fine, but I’m trying to make two changes, the first one is that I would like to this be just days1 and if the result of To_days( now( )) - TO_DAYS( o.date_payed) is empty use the second one.
The second change would be to instead of using To_days some way to use only weekdays, any ideas are welcome.
For the first question you can use IF function, ie
For the second part you can use the date_format function, ie
DATE_FORMAT(o.date_payed, '%w').