T-SQL Date Filtering Not Returning Expected Results in SQL Server 2017
I'm having a hard time understanding I'm working with a perplexing scenario with date filtering in my T-SQL query using SQL Server 2017. I have a table `Orders` with a `CreatedDate` column of type `DATETIME`, and I'm trying to filter records created on a specific date. However, when I run the following query, it returns no results, even though I know there are records for that date: ```sql SELECT * FROM Orders WHERE CAST(CreatedDate AS DATE) = '2023-10-10'; ``` I have checked the data in the `CreatedDate` column directly and confirmed that there are indeed some entries from the date `2023-10-10`. To troubleshoot, I've attempted to use the `BETWEEN` clause as well: ```sql SELECT * FROM Orders WHERE CreatedDate BETWEEN '2023-10-10 00:00:00' AND '2023-10-10 23:59:59'; ``` This also returned no results. I verified that the time zone settings of my SQL Server instance align with the timestamps in the database, so there shouldn’t be any discrepancies there. Additionally, I tried running the following to confirm the presence of dates in that range: ```sql SELECT DISTINCT CAST(CreatedDate AS DATE) AS OrderDate FROM Orders; ``` This query listed several distinct dates, including `2023-10-10`, but the filtering approaches I've used are not yielding any rows for that day. Is there something I might be overlooking or a best practice for filtering dates that I should be aware of? Any help would be greatly appreciated! My team is using T-Sql for this microservice. Am I missing something obvious?