I have a query that takes 2 datetimes as parameters and I need to write a where clause to get the records that are in between. These are not just dates but dates with times (ie. 1/28/2012 9:45)
So far, I this:
where d.RecordDateTime > StartDate && d.RecordDateTime < EndDate
Should I be rewritting these as:
where d.RecordDateTime > StartDate.Date && d.RecordDateTime < EndDate.Date
or is it fine as is.
Thanks.
Your current query definitley works… depending whether you want the result to include
StartDateand/orEndDateit should be changed a little bit:IF you change the query as you proposed in your question then you would make it include all in the result independent of time – although it would miss rows with a time like 00:00:00 or even miss a whole day (the
EndDate).