Pre-5.0.30 ADDTIME()

For when you want to add times greater than 839 hours.

CREATE FUNCTION ADDTIME_OLD(d datetime, t varchar(12))
RETURNS datetime
DETERMINISTIC
RETURN ADDTIME(
d + INTERVAL SUBSTRING_INDEX(t, ‘:’, 1) HOUR,
CONCAT(IF(LEFT(t, 1) = ‘-‘, ‘-‘, ”), ’00:’, SUBSTRING_INDEX(t, ‘:’, -2))
);

(Almost the same. I’m not going to figure out how to do the “you can use any delimiter you want” that MySQL supports.)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.