View Full Version : Anyone knows how to query according to the date..
08-28-2007, 09:17 AM
Id like to have a query depending on what is the date today. Its like a sort of reminder.
example. I have insert an action "Call Mr. Smith" and the date assigned is 2007-08-29 so by tommorow when i open my list of actions it will appear the the said "Call Mr. Smith" .
my query is
Select * from schedule where enddate<=NOW()
but this query will display all the enddate that less than 2007..
08-28-2007, 09:41 AM
$datenow = date("Y-m-d");
$sql = "SELECT * FROM schedule WHERE enddate = '$datenow'";
$sql = "SELECT * FROM schedule WHERE enddate >= '$datenow 00:00' AND enddate <= '$datenow 23:59'";
depends whether field is date or datetime
08-28-2007, 10:13 AM
what if i want to display list of actions which less than end date assigned..
heres the scenario..
2007-08-23 - meeting
2007-08-24 - call smith
2007-08-25- 1st interview
2007-08-26- 2nd inteview
2007-08-29- call smith
the very end date is 2007-08-31, therefore the actions displays are from 2007-08-28 to 2007-08-31, or todays date to very last date..
08-28-2007, 10:21 AM
$sql = "SELECT * FROM schedule WHERE startdate >= '$datenow' OR enddate >= '$datenow'";
08-28-2007, 10:27 AM
Thanks Bahamut.. ;)
08-28-2007, 02:04 PM
You can use the SQL function CURDATE() instead of using a PHP function:
$sql = "SELECT * FROM schedule WHERE startdate >= CURDATE() OR enddate >= CURDATE();";
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.