Where Condition not working for DATEs

Discussion in 'C#' started by praveenk, Nov 20, 2007.

  1. #1
    Hi,

    In my application search does'nt work for DATE but it works for numbers.

    When i kept a response.write(strSQL) here is the output..

    Not working for date---

    SELECT ID,ProcessOrder,DateOfProduction,IBMNo,SAP,SapName,StorageBin FROM tblShelfData WHERE Plant=0 AND DateOfProduction LIKE '%10/10/2004%' ORDER BY ProcessOrder asc

    follwing Works for number---

    SELECT ID,ProcessOrder,DateOfProduction,IBMNo,SAP,SapName,StorageBin FROM tblShelfData WHERE Plant=0 AND SAP LIKE '%2000000907%' ORDER BY ProcessOrder asc



    Any ideas?

    Praveen
     
    praveenk, Nov 20, 2007 IP
  2. Indian_Webmaster

    Indian_Webmaster Banned

    Messages:
    1,289
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think you can't use LIKE for Dates dude... Use >, < or = Only...
     
    Indian_Webmaster, Nov 20, 2007 IP
  3. orielo

    orielo Peon

    Messages:
    175
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    indian webmaster is quite right,
    there you go :
    SELECT * FROM DATE_SAMPLE 
    WHERE SAMPLE_DATE >= '2003-04-09' 
    AND SAMPLE_DATE <'2003-04-10'
    
    Code (markup):
     
    orielo, Nov 20, 2007 IP