Mobile Line Of Business

Richard Jones (MVP)

  Home  |   Contact  |   Syndication    |   Login
  202 Posts | 0 Stories | 36 Comments | 0 Trackbacks

News

Welcome to the Mobile Line Of Business Blog

Tag Cloud


Archives

Post Categories

About

Ever needed to-do this in SQL?

select * from ATABLE

where [SomeDate]=@A_DATE_YOU_WANT_TO_LOOKFO

Now suppose that you want to ignore times as SQL Server's DateTime object stores the time along with the date.

You can modify the query to-do just this.

select * from ATABLE

CAST(FLOOR(CAST( [SomeDate] AS float)) AS datetime) = @A_DATE_YOU_WANT_TO_LOOKFO

 

Obviously the variable @A_DATE_YOU_WANT_TO_LOOKFO should  have its time set to midnight,  but this works great.

posted on Sunday, November 23, 2008 8:41 AM