In article <A733FF9B1FB0F441B3A6209FF71030E501065A00@bondsteel2.areur.army.mil>, Peter.Thoenen@bondsteel2.areur.army.mil says... > Hello, > > Curious if there is an easier way to do this (using just SQL and not PHP). > SQL seems powerful enough to do this but can't think of the synatx. Note, I > am using MySQL so no sub-selects (or other useful items). Basically trying > to pull all records for a 24 hour period but instead of 0000->2400, > 0700->0700 (next day). > > if (date("H")>7){ > > $query=mysql_query(" > SELECT dtg > FROM techs > WHERE > tech='$user' > AND > DAYOFMONTH(NOW())=DAYOFMONTH(dtg) > AND > HOUR(dtg)>=7 > "); > > } else { > > $query=mysql_query(" > SELECT dtg > FROM techs > WHERE > tech='$user' > AND > ( > (DAYOFMONTH(NOW())=DAYOFMONTH(dtg) AND HOUR(dtg)<7) > OR > ((DAYOFMONTH(NOW())-1)=DAYOFMONTH(dtg) AND HOUR(dtg)>=7) > ) > "); > > } > > Cheers, > > -peter I'd imagine that with a judicious use of mysql's IF statement and HOUR(NOW()) you could do pretty much what you want. I can't be hanged going through the docs right now, or I'd have a try at the syntax for you :-) -- David Robley Temporary Kiwi! Quod subigo farinam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php