| |||||||||||
Select records from March Posted by bschultz (bschultz), 30 April 2008 I'm trying to select only records from the month of March.I've tried... $sql = "SELECT date, title, text FROM table ORDER by date DESC WHERE `date` = DATE_SUB(CURDATE(),INTERVAL -2 month)"; and this... $sql = "SELECT date, title, text FROM brian ORDER by date DESC WHERE `date` BETWEEN DATE_SUB(CURDATE( ) ,INTERVAL -2 MONTH) AND CURDATE( )"; Neither are working. Can anyone help, please? Posted by admin (Graham Ellis), 30 April 2008 The first thing I notice is that you have quotes around date - you have written 'date' when I think it should be date. With quotes you are looking to match exactly the letters d-a-t-e and not the contents of a field called date ...Posted by bschultz (bschultz), 30 April 2008 Didn't work...I still get Quote:
I should add that "date" is set as timestamp (NOW) in the DB. I have also tried this code Code:
Which does display the proper results, but the dates are messed up. 2008-03-28 reads Wednesday, December 31, 1969 - 6:00 pm with this code Code:
Posted by bschultz (bschultz), 30 April 2008 this code worksCode:
Thanks, Graham! This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |