MySQL datediff strange results -


i getting weird results datediff function. it's 0 different , same timestamps?

select datediff('2015-04-25 20:37:45','2015-04-25 05:20:00'); +-------------------------------------------------------+ | datediff('2015-04-25 20:37:45','2015-04-25 05:20:00') | +-------------------------------------------------------+ |                                                     0 | +-------------------------------------------------------+  select datediff('2015-04-25 20:37:45','2015-04-25 20:37:45'); +-------------------------------------------------------+ | datediff('2015-04-25 20:37:45','2015-04-25 20:37:45') | +-------------------------------------------------------+ |                                                     0 | +-------------------------------------------------------+ 

if @ mysql manual:

datediff
datediff() returns expr1 − expr2 expressed value in days 1 date other. expr1 , expr2 date or date-and-time expressions. date parts of values used in calculation

so getting correct.

if looking time difference, suggest looking timediff or timestampdiff.

if difference in minutes, best way timestampdiff.

here example of how it:

select timestampdiff(minute, '2015-04-25 20:37:45','2015-04-25 05:20:00'); +--------------------------------------------------------------------+ | timestampdiff(minute, '2015-04-25 20:37:45','2015-04-25 05:20:00') | +--------------------------------------------------------------------+ |                                                               -917 | +--------------------------------------------------------------------+ 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -