Scott Haneda <[EMAIL PROTECTED]> wrote on 07/06/2005 08:16:41 PM: > I am using 4.0.18-standard > So I do not have `DATEDIFF`, but I need to ability to do so, anyone know > some other simple trick to get days between two dates? > -- > ------------------------------------------------------------- > Scott Haneda Tel: 415.898.2602 > <http://www.newgeo.com> Novato, CA U.S.A. > > > Use UNIX_TIMESTAMP() to convert your dates into integers (seconds) and convert
Here's how I would compute the # of days between 2005-01-01 06:00:00 and 2005-02-01 18:00:00 (it should be 31 days 12 hours or 31.5) localhost.(none)>select (UNIX_TIMESTAMP('2005-02-01 18:00:00')-UNIX_TIMESTAMP('2005-01-01 06:00:00'))/(60*60*24); +------------------------------------------------------------------------------------------+ | (UNIX_TIMESTAMP('2005-02-01 18:00:00')-UNIX_TIMESTAMP('2005-01-01 06:00:00'))/(60*60*24) | +------------------------------------------------------------------------------------------+ | 31.50 | +------------------------------------------------------------------------------------------+ See how that works? (Difference in seconds)/(seconds in a day) = difference in days Shawn Green Database Administrator Unimin Corporation - Spruce Pine