Answer the question
In order to leave comments, you need to log in
How can I write a sql query by date and time?
Hello everyone!
I have an InsertDate field in the table, where the data is in this format - '2020-07-07 10:00:00'.
Is it possible to somehow write a query to show records where InsertDate insert date goes from '2020-07-07 10:00:00' to '2020-07-08 09:30:00'?
Answer the question
In order to leave comments, you need to log in
select * from `table` where InsertDate between '2020-07-07 10:00:00' and '2020-07-08 09:30:00'
With datetime, they recommend a little differently:
SELECT *
FROM order_details
WHERE order_date BETWEEN CAST('2020-07-07 10:00:00' AS DATETIME) AND CAST('2020-07-08 09:30:00' AS DATETIME);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question