bahaa Posted November 23, 2011 Share Posted November 23, 2011 Hi all, I have a table with these fields :articalID, articalTitle, articalBody, articalPhoto, articalTags, articalPublishDate, articalView, articalVisible, userID, catID The articalPublishDate is a datetime type. FROM the CMS I set the date and times when the artical to be released or published. How do compare the articalPublishDate with the date and time now and select the row if date and time now equal or greater than the date and time in the table? Link to comment Share on other sites More sharing options...
Larry Posted November 23, 2011 Share Posted November 23, 2011 WHERE articalPublishDate >= NOW() Link to comment Share on other sites More sharing options...
bahaa Posted November 23, 2011 Author Share Posted November 23, 2011 But WHERE articalPublishDate >= NOW() will select future date? If I set an artical to be published in 2011-12-23 and use WHERE articalPublishDate >= NOW() then the artical will be published before 2011-12-23 comes Link to comment Share on other sites More sharing options...
Larry Posted November 23, 2011 Share Posted November 23, 2011 Sorry. Backwards. Just switch it around then. This is all in the book and in the MySQL manual, of course. Link to comment Share on other sites More sharing options...
bahaa Posted November 23, 2011 Author Share Posted November 23, 2011 I know it is in the manual but the odd thing that it doesn't include today's post for some reason. for example: if I have post with these dates 2011-11-22, 2011-11-24, 2011-11-19, 2011-11-18 It only select 2011-11-19, 2011-11-18 but not 2011-11-22 Link to comment Share on other sites More sharing options...
Larry Posted November 23, 2011 Share Posted November 23, 2011 Then your time is probably causing the problem. Link to comment Share on other sites More sharing options...
bahaa Posted November 23, 2011 Author Share Posted November 23, 2011 Yes, it is the time problem. I set the time to a different time zone that the server uses. I get my data insert with the date and time I want, but when I use now() in my query to select rows with them time I want, it uses the server time. How do I fix this? Link to comment Share on other sites More sharing options...
Recommended Posts