PHP - Moved: How To Get Data Between Two Same Dates When Datefield Is Datetime
This topic has been moved to MySQL Help.
http://www.phpfreaks.com/forums/index.php?topic=318249.0 Similar TutorialsHi All, I need to subtract dates and display the number of days left. I have a 'Start' date and an 'End' date in DATETIME format in the DB. Not quite sure where to start. A simply start - end doesn't work . Start = 2011-11-01-00:00:00 End = 2011-11-30-23:59:59 Since it is now 2011-11-27, my output should equal 3. Any help is appreciated. SELECT * FROM `booking_tbl` WHERE booking_status = 'Check In' AND departure_date_time = NOW()"I use the datetime datatype for the departure_date_time so i can get data from that data because it checking the date and time but i want it to check on the date from the datetime datatype So how can i get the data only with that date without the time in the mysql datetime datatype I am using a query to select everything out of a table in to an array. I have 4 fields as follows name, email, comment and datatime. What i want to do is use one of the stated function to grab the datetime elements and split them at the break point, but i am displaying more than one record with in the table, i think this is were i am fucking up. for example i tryied this: Code: [Select] $commentsTable = "comments"; $comments = "SELECT * FROM $commentsTable"; $commentResults = mysql_query($comments); $commentRows = mysql_fetch_array($commentResults); $dateTimeSplit = explode(" ", $commentRows['datetime']); <?php while($commentRows = mysql_fetch_array($commentResults)){?> <div id="comments"> <div id="CommentWrapper"> <div id="comment"> <div id="UserComment"><? echo $commentRows['comment'];?></div> // here is were am having the problem!!! <div id="PostDateTime"><i>Posted: </i><? echo $dateTimeSplit['0'];?><i> Time: </i><? echo $dateTimeSplit['1'];?></div> </div> </div> </div> <?php } mysql_close(); ?> any sudgestions? Hi, I'm trying to get the records that are between two dates to show on my screen, right now nothing comes up my code I'm using is below Code: [Select] $today = date('Y-m-d'); $lastweek = date('Y-m-d',strtotime('-7 days')); $sql = "SELECT * from `memos` WHERE `date` BETWEEN '$today' AND '$lastweek' AND `delete` !='1'"; $result = mysql_query($sql); echo "<ol>"; while ($row = mysql_fetch_array($result)) { echo "<li>".$row['memo']."</li>" ; } echo "</ol>"; Dear all, how can I convert a string "yyyy-mm-dd hh:mm" into a really datetime value with php? thanks! This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=320857.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=305964.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=321426.0 Hi guys, I am trying to do a multidates events availability calender. The script below indicates todays date by highlighting an orange colour and also indicates the start and end date of the event highlighting grey colour on the two dates (The colour are link via css classes as shown). Code: [Select] //Today's date $todaysDate = date("d/m/Y"); $dateToCompare = $daystring . '/' . $monthstring . '/' . $year; echo "<td align='center' "; if($todaysDate == $dateToCompare){ echo "class='today'"; }else{ //Compare's the event dates $sqlcount = "select event_start,event_end from b_calender where event_start ='".$dateToCompare."' AND event_end='".$dateToCompare."'"; $noOfEvent = mysql_num_rows(mysql_query($sqlcount)); if($noOfEvent >= 1){ echo "class='event'"; } } It works ok i.e. if start date = 01/01/2012 and end date = 04/01/2012 both date will be highlighted with grey colour. However I want it to also highlight grey on the dates between the 1st and 4th to show that then anydates between the 1st and 4th are not available and this is when I'm stuck. Please guys I need help. Thanks This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=351748.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=342944.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=314051.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=307094.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=346552.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=309496.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=347191.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=320895.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=352249.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=314247.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=319161.0 |