Firstly, my apologies as I know this is primarily a Microsoft area but wanted to know if, on the off chance, anyone can answer this conundrum I have.
I have a MySQL database table called Orders with a column order_date and some fictitious dates in 2008, and I have this code:
Code: Select all
SET @sDate = '2008-06-01';
SET @eDate = '2008-06-30';
SELECT * FROM Orders WHERE
order_date BETWEEN @sDate AND @eDate;
Which is basically showing orders in June 2008, and it works as expected. However, when I put in the @eDate to 2008-06-31 (Remembering June only has 30 days) it still works!!! But, if I put in @eDate to 2008-06-32 it fails as expected as no month has 32 days, so why does it work for 31 days?
I have tried it with similar results:
Code: Select all
SET @sDate = '2008-06-01';
SET @eDate = '2008-06-30';
SELECT * FROM Orders WHERE
order_date >= @sDate AND order_date <= @eDate;
There is always one bright spark in my lectures