Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get the data only on working hours

Is there a way to select or query the data only on working hours?

id description datetime
1 Alarm Activated 2022-01-02 14:00:00
2 Alarm Deactivated 2022-01-02 15:00:00
3 Alarm Activated 2022-01-03 18:00:00
.. Alarm Activated 2022-01-31 11:00:00

I’d like to get the number of the alarm activated on or during working hours from mon-fri 8am to 5pm.

I tried to use the between date but no luck.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

SELECT *        -- if you need to count them only - use SELECT COUNT(*)
FROM datatable
WHERE WEEKDAY(`datetime`) < 5                               -- test weekday
  AND TIME(`datetime`) BETWEEN '08:00:00' AND '17:00:00';   -- test hours
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading