C
C
CityzenUNDEAD2020-07-08 10:20:00
SQL
CityzenUNDEAD, 2020-07-08 10:20:00

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

2 answer(s)
R
Roman Sarvarov, 2020-07-08
@CityzenUNDEAD

select * from `table` where InsertDate between '2020-07-07 10:00:00' and '2020-07-08 09:30:00'

S
Stanislav Shendakov, 2020-07-08
@shindax

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 question

Ask a Question

731 491 924 answers to any question