Select the rows between 2 dates in MS SQL table
If you need to select the records between 2 dates in MS SQL, where the DateTime column contains both Date and Time, you can use SQL functions for WHERE clause and avoid of adding the time information like '23:59:59.000'. Though you can do it and this way.
Using function CAST:
where CAST(TIMESTAMP as date) between '2023-05-29' AND '2023-05-30'
Using function CONVERT:
where CONVERT(date, TIMESTAMP) between '2023-05-29' AND '2023-05-30'
The requests looks like these respectively:
SELECT Title, Timestamp, DocType from MyTable where CAST(TIMESTAMP as date) between '2023-05-29' AND '2023-05-30'
SELECT Title, Timestamp, DocType from MyTable where CONVERT(date, TIMESTAMP) between '2023-05-29' AND '2023-05-30'