J
J
jekahm2017-03-02 16:54:13
MySQL
jekahm, 2017-03-02 16:54:13

Date interval (+ time) in MySQL?

Dear time of day!
To select records in the interval of certain dates, namely yesterday and today, I use the trace. request:

SELECT * FROM matches WHERE (`match_date` >= CURDATE() - INTERVAL 1 DAY) AND (`match_date` < CURDATE() + INTERVAL 1 DAY)

But the problem is that we don't need a full yesterday, namely the last 3 hours (21:00 to 24:00)
How can this be implemented?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2017-03-02
@Rsa97

If `match_date` contains the time, then

`match_date` >= CURDATE() - INTERVAL 1 DAY + INTERVAL 21 HOUR

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question