in reply to Problem passing date to SQL

You're trying to perform a string comparison of the string '08/%/2015' with a date field, which is a number. This absolutely will not work in Microsoft SQL and I suspect (though can't test) that it won't work in Oracle either.

A better solution is: SELECT ... WHERE DATE >= $startdate AND DATE <= $enddate

UPDATE: Yeah, dunno who down-voted me, but there are some assumptions I made:

  • OP is using Oracle and checking monthly stats, so probably a professional environment
  • It then holds that OP probably has a DBA maintaining the DB
  • Following on from that, it is likely that the DB was properly designed / built
  • Given WHERE DATE LIKE ? won't work in Oracle, OPs statement about running the exact same SQL is blatantly untrue
  • Replies are listed 'Best First'.
    Re^2: Problem passing date to SQL
    by runrig (Abbot) on Aug 18, 2015 at 20:41 UTC
      Although a "WHERE date_column LIKE '...'" clause CAN work in Oracle, it is incredibly poor practice. You can not depend on the date format in any particular environment, and any indexes on the date column will not be used.

        Aah, that does work in Oracle? I stand corrected :)