0

I have seen different variations of this question before, but haven't seen an answer that works for me. I have a DATE_MODIFIED field that is a date/time field. I want to write a where clause on it and select the date using GETDATE(). That is, I want to be able to select the data for today's date regardless of the time the query is run. Can anyone provide any advice here? I'm still pretty new at this.

where DATE_MODIFIED = GETDATE()
Md. Zakir Hossain
  • 1,082
  • 11
  • 24
code_un-ninja
  • 35
  • 1
  • 7

1 Answers1

0

You can just do this

WHERE CAST(DATE_MODIFIED AS DATE) = CAST(GETDATE() AS DATE)

And, if you are interested in performance of date checks etc, this is a good read

http://sqlperformance.com/2012/09/t-sql-queries/what-is-the-most-efficient-way-to-trim-time-from-datetime

Steve Drake
  • 1,968
  • 2
  • 19
  • 41