PDA

View Full Version : Problem with this date format ?


jeddi
02-05-2010, 03:00 PM
Hi,
I am trying to use the mysql date funtion to select the
data that is 5 days old or newer.

This is what I have tried:

SELECT * FROM main WHERE start_date => (CURRENT_DATE() - 5 days ) ORDER BY start_date

I get an error.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=> (CURRENT_DATE() - 5 days ) ORDER BY start_date' at line 1


What have I done wrong?


.

abduraooft
02-05-2010, 03:07 PM
start_date =>
Did you mean start_date >= ?

jeddi
02-05-2010, 03:14 PM
Yep,

That was part of the problem :)

BUT I get a different error now:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'days ) ORDER BY start_date' at line 1

guelphdad
02-05-2010, 03:27 PM
Look up DATE_SUB and DATE_ADD in the manual.

jeddi
02-05-2010, 03:48 PM
Yep - that helped :thumbsup: