12 Replies Latest reply: Sep 27, 2012 8:41 AM by Sudeep Dhoju RSS

    getting stuck in SQL WHERE = Today when date is YYYYMMDD

      Hey,

       

      I'm trying to retrieve data, limiting it in SQL according to Today’s date.

      The problem is that the date is stored in YYYYMMDD format, therefore not in proper SQL format

      Things like

       

      WHERE Date = GetDate()
      

       

      Or


      DATEADD(day, 0, CURRENT_TIMESTAMP); 

       

      Or


      WHERE Date = CONVERT(CHAR(10),GETDATE(),112);

      WHERE Date = CONVERT(VARCHAR(8), GETDATE(), 112) AS [YYYYMMDD]

       

      If (to avoid confusion) we now define the field I need to look in for today’s date as MyField, how would the script look like?

       

      Load *;
      
      SQL SELECT
      Field1, Field2, MyField from Server.table WHERE MyField = (?);
      

       

      Thank you!