A Little Noise

September 25, 2013

Pre-5.0.30 ADDTIME()

Filed under: MySQL — snoyes @ 1:25 pm

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.)

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress