locked
Where Clause RRS feed

  • Question

  • I want to use a WHERE CLAUSE with the AND operator to find dates between 2015-03-01 and 2015-03-31 in a column. This is the line i am using but it returns nothing and I know there is data matchiung. WHERE Slot = 2 and ExpiratinoDate > 2015-03-01 and < 2015-03-31                     What is wrong with that statement

    
    
    
    Wednesday, March 11, 2015 6:12 AM

Answers

  • first you should check  datatype if it's right then try to use between clause on date function.

    ExpiratinoDate  between 2015-03-01  and 2015-03-31 

    • Marked as answer by Eric__Zhang Wednesday, March 18, 2015 5:21 AM
    Wednesday, March 11, 2015 6:28 AM

All replies

  • How ExpiratinoDate is stored in your table? What is the data type? It's date or varchar or something else?

    Could you provide sample dates that exists in your table?


    -Vaibhav Chaudhari

    Wednesday, March 11, 2015 6:17 AM
  • WHERE ExpirationDate BETWEEN '2015-03-01' AND '2015-03-31'

    WHERE ExpirationDate >= '2015-03-01' AND ExpirationDate <= '2015-03-31'
    • Edited by dave_gona Wednesday, March 11, 2015 6:25 AM
    • Proposed as answer by kumarvik Wednesday, March 11, 2015 6:51 AM
    Wednesday, March 11, 2015 6:21 AM
  • first you should check  datatype if it's right then try to use between clause on date function.

    ExpiratinoDate  between 2015-03-01  and 2015-03-31 

    • Marked as answer by Eric__Zhang Wednesday, March 18, 2015 5:21 AM
    Wednesday, March 11, 2015 6:28 AM