I have some php code that pulls from the mysql database.  Here it is:

         mysql_connect("", "webuser",
   $mymonth = date('n');
   $cyear = date('Y');
         $query = "SELECT name,hdate FROM emp2 where month(hdate)=$mymonth
order by hdate";
         $result = mysql_db_query("iweb", $query);

         if ($result) {
           echo "<table align=center  border=0  cellspacing=5 >";
           while ($r = mysql_fetch_array($result)) {
              $name = $r["name"];
     $hyear = date('Y',$r["hdate"]);
     $timein = $cyear - $hyear;
     if ($timein > 0) {
           echo "</table>";
         } else {
        echo "No data.";
    mysql_free_result($result); ?>

I'm trying to figure out years of employment based on hiredate.  Its not
working as expected.  $timein is always
1969.  Date in the database is YYYY-MM-DD.  What have I screwed up ?


PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to