on 01/31/2004 11:57 AM, Kenneth Letendre at [EMAIL PROTECTED] wrote: > Hello, > > I'm trying to get the difference (in days) between dates stored in two > date fields. > My query: > > SELECT id,(firstdate- postdate) AS diff FROM calendar > > This works fine if the two dates are in the same month, but not > otherwise. MySQL appears to be treating the two dates as base-10 integers > rather than dates. E.g.: > > 2004-01-07 (20,040,107) - 2003-12-31 (20,031,231) = 8876 > > How do I get MySQL to treat these date fields as date fields in this case?
Take a look at <http://www.mysql.com/doc/en/Date_and_time_functions.html> for the DATEDIFF() function. -- ------------------------------------------------------------- Scott Haneda Tel: 415.898.2602 http://www.newgeo.com Fax: 313.557.5052 [EMAIL PROTECTED] Novato, CA U.S.A. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]