How to restrict minutes in a time interval using Mysql

Asked

Viewed 31 times

1

I have a table that contains day, month, year, hour, minute and second. I need to return only the time between 8 and 11 o'clock, but do not want me to return from the 11 o'clock forward Example: 8:01 8:40 9:40 10:02 10:55 11:00 do not want you to return 11:01, 11:10...

 SELECT *
    FROM oi_fact.metrics_values mv
             JOIN oi_fact.dim_date dd ON mv.dtt_id = dd.dtt_id
    WHERE dmm_id in (select dmm_id from dim_metric where met_id IN (1136))
      and mv.nod_id = 168992
      AND mv.dtt_id between '202101010000' AND '202101302300'
      AND dd.hour >= 8 and dd.hour <= 11
    order by mv.dtt_id;
  • 1

    Something like dd.hour < 11 OR (dd.hour = 11 and dd.minute = 0 and dd.second = 0)?

1 answer

0

Here is a suggestion for testing:

  AND dd.hour * 10000 + dd.minute * 100 + dd.second between 80000 and 110000

I hope it helps

Browser other questions tagged

You are not signed in. Login or sign up in order to post.