D
D
dienerie2021-08-06 11:11:06
SQL
dienerie, 2021-08-06 11:11:06

How to select rows by time no earlier than 30 and no later than 60 minutes?

I try that, but for some reason it doesn't work.
Shows records both later and earlier.
And it is necessary in the interval, for example - the current time is 14:00.
If the entry arrived at 13:50, do not display it.
If the entry arrived at 13:00, do not display it.
If the entry arrived at 13:20, then display .

It is necessary to take records in the interval during the last hour, but not earlier than half an hour.

The time is specified in the format 2021-08-06 10:18:55 (time field).

SELECT id, username, time 
FROM basesite.spisok 
where time >= DATE_SUB(now(), INTERVAL 60 MINUTE) 
  and MINUTE(time) > 30;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2021-08-06
@Rsa97

WHERE `time` BETWEEN NOW() - INTERVAL 60 MINUTE AND NOW() - INTERVAL 30 MINUTE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question