uniboy86 Posted January 24, 2008 Share Posted January 24, 2008 <?php require "connect.php"; $today = Date('Y-m-d'); $query = "Select * from booking where arrivaldate=".$today; $result = mysql_query($query, $connection) or die("Unable to perform query<br>$query"); ?> <html> <head> <title>Date</title> </head> <body> <?php print $today ?> <?php while($row=mysql_fetch_array($result)) { ?> <?=$row['BookingId']?><br> <?=$row['arrivaldate']?><br> <?=$row['DepartureDate']?><br> <? } ?> </body> </html> I would like to know what the syntax i use to compare the current date to the ArrivalDate in a database table. I have checked the date formats and they are as follows: YYYY-MM-DD Can some please help with how I do the query to check dates against current date Quote Link to comment Share on other sites More sharing options...
fenway Posted January 24, 2008 Share Posted January 24, 2008 What format is $today? Quote Link to comment Share on other sites More sharing options...
Barand Posted January 25, 2008 Share Posted January 25, 2008 More to the point, what format is arrivaldate? If it's DATE type, you can use $query = "Select * from booking where arrivaldate=CURDATE()"; ElseIf it's DATETIME, you can use $query = "Select * from booking where DATE(arrivaldate)=CURDATE()"; Else Better tell us. Quote Link to comment Share on other sites More sharing options...
uniboy86 Posted February 12, 2008 Author Share Posted February 12, 2008 A bit late I solved the problems I forgot which forum i posted on but I used the curdate() function as my dates are in the date format in my mysql database. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.