MySQL Forums
Forum List  »  PHP

How to calculate time difference
Posted by: janakiraman t
Date: November 01, 2006 01:42AM


I have a column called timeinterval which is of type datetime. I need to select the first and the second timeinterval and find the difference between them. if it is greater than 30 seconds i need to do something. how to achieve this. I tried using datediff and timediff.

select TIMEDIFF ('2006-10-31 11:50:31' , '2006-10-31 11:50:01')
select DATEDIFF ('2006-10-31 11:50:31' , '2006-10-31 11:50:01')

but it is saying you have an error in sql syntax. Iam using mysql 4.1.0 version.

one more thing. If the query works fine how can i check whether it is greater than 30 seconds. If suppose it is greater than one day it is going to return 1. How to check this condition also.


Options: ReplyQuote

Written By
How to calculate time difference
November 01, 2006 01:42AM
d d
November 19, 2008 01:00AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.