website page counter

Mysql Timediff In Hours And Minutes

The best Images

Mysql Timediff In Hours And Minutes. Of course i could parse it manually but i don t want to shift the load to the script engine if mysql can do it in a single call. To fix this problem you need to use the timestampdiff function as follows.

Pin On Nicesnippets Com
Pin On Nicesnippets Com from www.pinterest.com

This article looks at the difference between the mysql timediff and timestampdiff functions. The way it works is you provide the two values to compare and timediff subtracts the second value from the first then returns the result as a time value. The mysql timediff function returns the difference between two time or datetime values.

To fix this problem you need to use the timestampdiff function as follows.

So the result should be 1416 hours however as we mentioned earlier the result of the timediff function is a time value which ranges from 838 59 59 to 838 59 59. The way it works is you provide the two values to compare and timediff subtracts the second value from the first then returns the result as a time value. Timediff expr1 expr2 where expr1 and expr2 are the two values to compare. It is to be noted that two expressions must be the same type.

close