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

##################################
Peter Thoenen - Systems Programmer
Commercial Communications
Camp Bondsteel, Kosovo
##################################

"Stumbled Upon"...heh (Score:5, Funny) /.
by $carab on 23:00 23 August 2002 (#4131637)

"ForensicTec officials said they stumbled upon the military networks about
two months ago, while checking on network security for a private-sector
client."

Someone new to a Dvorak probably tried to type in "lynx
http://www.google.com"; but instead got "nmap -v -p 1-1024 -sS -P0 army.mil
-T paranoid".

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to