Explore Courses Blog Tutorials Interview Questions
0 votes
in SQL by (6.1k points)
I want to write a query that will take all the rows in a particularised date range and time range.

For example, I need to query all the rows from 6:00 PM on 10-Sep-2020 to 10:00 AM on 22-Sep-2020.

Any thoughts as to how the query should be?

1 Answer

0 votes
by (12.7k points)
edited by

You can use the following query to get all the rows in a specified date range and time range.

 FROM myTable
 WHERE CAST(ReadDate AS DATETIME) + ReadTime BETWEEN '2020-09-10 6:00PM' AND '2020-09-22 10:00AM'

The above will show data as per the specified date.

Are you interested to learn SQL in detail? Join this SQL Training course by Intellipaat.

Related questions

Browse Categories