Skip to content
Advertisement

SQL Query between a date range and a time range in MariaDB

I’m having trouble writing this query to give me any results. I’m using MariaDB as well.

The DATE_ADD clause works just fine and gives results within that interval, but as soon as I add in the TIME function nothing is returned in the results. The CallDate format is 2021-09-21 HH:MM:SS I have tried using HOUR as well in place of TIME, but it also returns nothing.

I’m trying to pull calls from any day within the range specified in the DATE_ADD clause. As long as it’s between 1700 and 0800 (after hours calls).

Advertisement

Answer

I think you need to check both dates something like this and adjust the times used on each date as well

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement