How to give select between one hour_minute and another in SQL

0

I need to resolve a simple exercise requesting to report the amount of books sold between 1:00 pm and 5:30 pm on all dates.

I was able to pull between 13h and 17h but not with the "17h30" minutes.

I did so:

SELECT SUM(quantidade) 
FROM notafiscal WHERE extract(hour FROM data_compra) BETWEEN 13 AND 17;

I tried using hour_minute instead of hour and by '17: 30 'but back as null any result.

    
asked by anonymous 10.09.2017 / 06:06

1 answer

0

Try converting to text:

SELECT SUM(quantidade) 
FROM notafiscal 
WHERE DATE_FORMAT(Data_compra, '%T') BETWEEN '13:00:00' AND '17:30:00'
    
10.09.2017 / 14:41