SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,049 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
WHERE insertTimestamp >= @date
AND InsertTimestamp < dateadd(DAY, 1, @date)