CoderZone.org

Category: >> mySQL >> Calculate TIMEDIFF with mysql version < 4.1 Bookmark and Share

<< lastnext >>

Snippet Name: Calculate TIMEDIFF with mysql version < 4.1

Description: Calculate the time difference between two dates with the result is in seconds.

Comment: (none)

Author: CoderZone
Language: MYSQL
Highlight Mode: MYSQL
Last Modified: March 01st, 2009

// TIMEDIFF between two dates and the result is in seconds
SELECT ((TO_DAYS(DATE_FORMAT('1997-10-04 22:23:00', '%Y-%m-%d')) * 86400) +
        TIME_TO_SEC(DATE_FORMAT('1997-10-04 22:24:00', '%T')))
- ((TO_DAYS(DATE_FORMAT('1997-10-04 22:24:00', '%Y-%m-%d')) * 86400) +
        TIME_TO_SEC(DATE_FORMAT('1997-10-04 22:22:00', '%T')))
 
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 6