SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

mattech13
Starting Member

4 Posts

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

date format's, I love em ;)

I have this code..


Select ReferralKPI_MainOMSView.dbPatID,
 ReferralKPI_MainOMSView.dbPatLastName,
 ReferralKPI_MainOMSView.dbAddDate,
 ReferralKPI_MainOMSView.LastName,
 ReferralKPI_MainOMSView.dbStaffLastName
 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.

thanks

khtan
In (Som, Ni, Yak)

Singapore
17595 Posts

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

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



KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.03 seconds. Powered By: Snitz Forums 2000