WHERE insertTimestamp >= @date
AND InsertTimestamp < dateadd(DAY, 1, @date)
better query for select results based on date.
Jonathan Brotto
420
Reputation points
What is the best way to write this code to get the date results? I have the time throughout the day in the datetime field.
SELECT * FROM Reconciliation.Documents D
Inner Join Reconciliation.DocumentsTransaction T
ON D.DocumentPKey = T.DocumentPKey
WHERE
PartnerID = 'Busdepot' AND EDIDirection = 'inbound'
and EDITransactionType = '850'
and year(InsertTimestamp) = year('2024-09-18')
and month(InsertTimestamp) = month('2024-09-18')
and day(InsertTimestamp) = day('2024-09-18')
ORDER BY d.DocumentPKey
SQL Server | SQL Server Transact-SQL
Developer technologies | Transact-SQL
Developer technologies | Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
SQL Server | Other
Answer accepted by question author
-
Erland Sommarskog 128.9K Reputation points MVP Volunteer Moderator2024-09-30T21:18:01.41+00:00