Last active
February 7, 2017 09:10
-
-
Save roylee0704/ecf14e737d1b0a3e80f3002f2d2db542 to your computer and use it in GitHub Desktop.
check is within period/time_frame if is_time_based = 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * | |
FROM gb_m_promo p | |
LEFT JOIN gb_n_promo_period t ON p.promo_code = t.promo_code | |
WHERE TRUE | |
AND CASE WHEN is_time_based = 1 THEN CURTIME() BETWEEN from_time AND to_time ELSE TRUE END; | |
# time diff | |
SELECT TIMESTAMPDIFF(SECOND, '2012-06-06 13:13:55', '2012-06-06 15:20:18') | |
# date.add/date.sub | |
SELECT DATE_ADD(starts_at, INTERVAL ((execution_count+ 1) * duration_day) DAY); | |
# time.add/time.sub | |
select ADDTIME('00:00:00', '07:00:00'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment