Also, I couldn't find a simple SQL way to cast ClearDate to a Date field - I've read the ODBC SQL date functions, and unless I'm missing something, I think I'm out of luck. All the examples I could find involved writing a VB function to do it, which would be silly to emulate here. Any Access SQL wizards?

my $report_date = "\#".&UnixDate(&ParseDate("3/19/2003"), "%m%/ +%d%/%Y")."\#"; my $start_date = "\#".&UnixDate(&ParseDate("3/19/2003"), "%m%/% +d%/%Y")."\#"; my $end_date = "\#".&UnixDate(&ParseDate("3/20/2003"), "%m%/%d% +/%Y")."\#"; my ($DaysOpen, $Priority, $Status) = undef; my ($WO2, $Ticket, $DateOpened, $ClearDate, $SiteCode, $Problem1, $Si +teCall1, $Dispatch, $Troubleshooting, $Solution1 )= undef; $sqlstatement= qq ( SELECT WorkOrd.WO2, WorkOrd.ClearDate from WorkOrd where WorkOrd.StatCode5 = 'C' and ( WorkOrd.ClearDate is NULL or ( WorkOrd.ClearDate BETWEEN ? and ? ) ) ); print("Report run on $report_date \t Report runs from $start_date to $ +end_date.\n"); $sth = $dbh->prepare($sqlstatement) or die "Could not prepare stateme +nt. Error:$sth->errstr()\n"; $sth->execute($start_date, $end_date) or die "Could not execute state +ment. Error:$sth->errstr()\n";
This seems to insert the hash-marks properly into the strings, because the print("Report...") statement works correctly, but ODBC poops on me like this
DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access Driver +] Data type mismatch in criteria expression. (SQL-22005)(DBD: st_execute/SQLExecute err=-1) + at O:\Scripts\Perl\ServiceReports\av-citigroup.pl line 54. Uncaught exception from user code: Could not execute statement. Error:DBI::st=HASH(0x21181c8)->errstr +() Report run on #03/19/2003# Report runs from #03/19/2003# to #03/2 +0/2003#.
If I don't use placeholders, I get this:
Report run on #03/19/2003# Report runs from #03/19/2003# to #03/2 +0/2003#. 38706 2003-03-19 14:17:01 38747 2003-03-19 18:40:42 38803 2003-03-19 15:26:40 38848

In reply to Re: Re: DBD::ODBC, Access, date comparisons by finni
in thread DBD::ODBC, Access, date comparisons by finni

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.