Answer the question
In order to leave comments, you need to log in
Calendar in Mysql DB?
Is it possible to create a table with dates and times, for example:
from 01.00 01.01.2017
02.00 01.01.2017
....
to 24.00 12.31.2017
or will you have to type everything manually?
Answer the question
In order to leave comments, you need to log in
Can.
SELECT '2017-01-01' + INTERVAL `d`.`dayOfYear` DAY + INTERVAL `h`.`hour` HOUR
FROM (
SELECT (`c`.`num`*100+`d`.`num`*10+`s`.`num`) AS `dayOfYear`
FROM (
SELECT 0 AS `num`
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7
UNION SELECT 8
UNION SELECT 9
) AS `s`
JOIN (
SELECT 0 AS `num`
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7
UNION SELECT 8
UNION SELECT 9
) AS `d` ON TRUE
JOIN (
SELECT 0 AS `num`
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7
UNION SELECT 8
UNION SELECT 9
) AS `c` ON TRUE
HAVING `dayOfYear` < DAYOFYEAR('2017-12-31')
) AS `d`
JOIN (
SELECT 0 AS `hour`
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7
UNION SELECT 8
UNION SELECT 9
UNION SELECT 10
UNION SELECT 11
UNION SELECT 12
UNION SELECT 13
UNION SELECT 14
UNION SELECT 15
UNION SELECT 16
UNION SELECT 17
UNION SELECT 18
UNION SELECT 19
UNION SELECT 20
UNION SELECT 21
UNION SELECT 22
UNION SELECT 23
) AS `h` ON TRUE
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question