By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,659 Members | 1,611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,659 IT Pros & Developers. It's quick & easy.

Getting error in mssql database query - Date

P: 3
Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(*) AS NumberOfRows FROM a_poll_votes 
  2. WHERE QUESTION_ID='1' 
  3. AND DATE_SUB(CURDATE(),INTERVAL 0 DAY) <= DATE_FORMAT(DT, '%Y-%m-%d') 
  4. AND IP='111.111.1.1'
  5.  
I think I am making mistake here:

DATE_SUB(CURDATE(),INTERVAL 0 DAY) <= DATE_FORMAT(DT, '%Y-%m-%d')

Can anbody plz help me.

This needs to be in asp and mssql

Thanks
Apr 17 '11 #1
Share this Question
Share on Google+
1 Reply


code green
Expert 100+
P: 1,726
Well, you haven't posted the error, but this does look odd
Expand|Select|Wrap|Line Numbers
  1. DATE_SUB(CURDATE(),INTERVAL 0 DAY) <= DATE_FORMAT(DT, '%Y-%m-%d')
This is not how date comparisons are done in SQL.
What filter are you tying to apply here, and is DT a DATETIME data type field. Hopefuly yes
Apr 18 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.