Is it possible to calculate difference between two timestamps in MySQL and get output result in seconds?
Like 2010-11-29 13:16:55 - 2010-11-29 13:13:55 should give 180 seconds.
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the UNIX_TIMESTAMP function to convert the DATETIME into the value in seconds, starting from Jan 1st, 1970:
Result:
An easy way to deal with if you’re not sure which value is bigger than the other — use the ABS function: