V
V
Viktoria Smirnova2018-04-06 09:27:52
MySQL
Viktoria Smirnova, 2018-04-06 09:27:52

Requesting a period of time during the day?

I apologize for the lamer question, I need a simple query to the database (MySql) with the output of the number of 15 minute intervals in the period from 09.00 to 18.00 hours, and recording them all in separate rows of the table with the minut_15 (Timestamp) field.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2018-04-06
@Vika7

SELECT CONCAT(`h`.`hour`, ':', `m`.`minute`, ':00')
FROM (
  SELECT '09' AS `hour`
  UNION SELECT '10'
  UNION SELECT '11'
  UNION SELECT '12'
  UNION SELECT '13'
  UNION SELECT '14'
  UNION SELECT '15'
  UNION SELECT '16'
  UNION SELECT '17'
) AS `h`
JOIN (
  SELECT '00' AS `minute`
  UNION SELECT '15'
  UNION SELECT '30'
  UNION SELECT '45'
) AS `m`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question