Bug #23569 The calling convention of TIMESTAMPDIFF() is counter-intuitive
Submitted: 24 Oct 2006 3:22 Modified: 24 Oct 2006 8:13
Reporter: Siu Ching Pong (Asuka Kenji) (Basic Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S4 (Feature request)
Version:5.0.24a-community-nt OS:Windows (Windows XP Professional)
Assigned to: CPU Architecture:Any
Tags: DATEDIFF, DATEDIFF(), TIMESTAMPDIFF, TIMESTAMPDIFF()

[24 Oct 2006 3:22] Siu Ching Pong (Asuka Kenji)
Description:
The calling convention of TIMESTAMPDIFF() is counter-intuitive, because it is just the opposite of all other xxxDIFF() date time functions.

DATEDIFF(), PERIOD_DIFF() and TIMEDIFF() return a postive integer if expr1 is "greater" than expr2. However, the opposite is true for TIMESTAMPDIFF(). This is so confusing ...

How to repeat:
See the dunmp file.

Suggested fix:
Create a new function, e.g. TIMESTAMP_DIFF(), which does it in the more intuitive way, because many people have already used the TIMESTAMPDIFF() function.
[24 Oct 2006 3:23] Siu Ching Pong (Asuka Kenji)
How To Repeat

Attachment: dump.txt (text/plain), 621 bytes.

[24 Oct 2006 8:13] Valeriy Kravchuk
Thank you for a reasonable feature request. 

Manual page http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html may benefit from some more clear description of what TIMESTAMPDIFF does (not just examples) also.