Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Date comparison problem
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

4 Posts

Posted - 09/15/2013 :  08:10:31  Show Profile  Reply with Quote

date format's, I love em ;)

I have this code..

Select ReferralKPI_MainOMSView.dbPatID,
 From ReferralKPI_MainOMSView
 Where (ReferralKPI_MainOMSView.dbAddDate <= '2013 Apr')
 AND (ReferralKPI_MainOMSView.dbStaffLastName IN ('') OR '' = '')
 AND (ReferralKPI_MainOMSView.LastName IN ('Hameed') OR 'Hameed' = '')

where the date is passed through in that format YYYY MMM ( I think as a string but maybe a datetime type)

the dbAddDate is in the typical datetime format yyyy-mm-dd hh:mm:ss

and surprisingly it almost works, it brings back all rows who's date is LESS than 2013 Apr BUT not equal to Apr and in fact that's all I want, rows that are EQUAL to, in this case 2013 Apr.

I tried just dropping the '<' part of the operator but it doesn't bring back any rows.

with my limited sql knowledge I'm stumped.


In (Som, Ni, Yak)

17689 Posts

Posted - 09/16/2013 :  00:05:04  Show Profile  Reply with Quote

Where (ReferralKPI_MainOMSView.dbAddDate < dateadd(month, 1, convert(datetime, '2013 Apr'))

Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000