Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
November 2, 2005, 10:48 pm
rate this thread
PHP and mysql
I have the following select statement whch gives me a count for
downloads for previous day.
date = current_date()-1
This works on every day of the month except the 1st day....so on 1st
November my values for 31 Oct showed 0 even though elsewhere I could see
that there was activity. It was the same on 1 Oct for 30th Sept and
will be no doubt the same on 1st Dec for 30 Nov.
Any ideas on why it shows zero? Does current_date()-1 have problems
when it's the first day of month?
Cure found for Bird Flu!
Re: current_date()-1 misbehaving on first day of month
This isn't a reasonable way to do date math.
and observe that it makes sense on *NO* days of the month.
It's doing INTEGER, not DATE, math.
select subdate(current_date(), INTERVAL 40 DAY);
current_date()-1 makes about as much sense as current_date()/2.583
(none at all). It's a coding error regardless of what day of the
month it is. Even a stopped clock is sometimes right.
Learn about adddate() and subdate().
Gordon L. Burditt