Forum Moderators: open

Message Too Old, No Replies

Subtracting Dates in MySQL

Can you subtract one datetime rows from another datetime place?

         

sawatkins

7:30 pm on May 6, 2008 (gmt 0)

10+ Year Member



The title pretty much says it all. I have two rows formatted in datetime. Can I subtract one from the other, like

SELECT DATE_SUB(`endtime`, `starttime`)

Thanks in advance for the help!

</g>

ashish21cool

7:09 am on May 7, 2008 (gmt 0)

10+ Year Member



try to subtract using "-"
Datetime1 - Datetime2
Let me know if this solves you problem.

rocknbil

6:49 pm on May 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sure you can, but I think you are looking for datediff() [dev.mysql.com] or timediff() [dev.mysql.com].