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

  • In reply to Re: Problem passing date to SQL by SimonPratt
    in thread Problem passing date to SQL by JoeTheProgrammer

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.