Using current_date() - 1 for today produces:
20170500
How come mySQL is not smart enough to know that it should be:
20170430
This is messing up the reports that I have on my website.
Thank you.
Using current_date() - 1 for today produces:
20170500
How come mySQL is not smart enough to know that it should be:
20170430
This is messing up the reports that I have on my website.
Thank you.
The bigger question is why aren’t you using DATE_SUB
Granted, I’m 90% certain you can also get away with current_date() - INTERVAL 1 DAY
, but DATE_SUB seems like a much safer choice.
how come you haven’t heard of date interval expressions?
SELECT CURRENT_DATE - INTERVAL 1 DAY AS yesterday ...
“seems” being the operative word
DATE_SUB is not standard SQL – date intervals are
To be far, if you follow the link it indicates it as an alias for DATE_ADD, which also seems safer than current_date() - 1
, plus, I already indicated the INTERVAL 1 DAY
Thank you both. I’m good to go now.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.