Here is some code from a very old version of a CGI/Mysql timesheet system I wrote. I used both Date::Manip and SQL date calculation commands. Maybe it will help.

The program basically lets you record how many hours a day you spend on any of your clients, in a view which covers all clients for a 1 week period. Due to user requests, a function was later added which let them log in to past weeks (to make up for unrecorded hours) by selecting a pulldown menu at login time which had items such as "2 weeks ago". So I think your idea was completely valid.

I can tell you that Date::Manip is great, but is also one of the two or three biggest modules on CPAN, if memory matters. As for quoting, maybe DATE_ADD will solve it for you?

Some Date::Manip (mainly used for day of the week type stuff): $companystartdate = &ParseDate("today"); # returns 2000082415:40:44 +format $companystartdate =~ s/^(....)(..).+/$1-$2-01/; # build 2000-08-01 Some SQL: my $statement = "select * from charges where (UserId='$userhash{'UserId'}' AND (Date BETWEEN '$start' AND DATE_ADD('$start', interval 6 day) ) ) order by ClientGroupId,ClientId,Date"; and my $monthstart = substr($sqlstartdate,0,8) . "01"; # 2000-08-01 my $monthend = "DATE_SUB( ( DATE_ADD('$monthstart',interval 1 month) ), Interval 1 day)"; # 1mo less 1dy. too many parens? my $statement="select sum(Hours) from charges where (UserId='$userhash{'UserId'}' and ClientId='$client' and FeeType='$fee' and Date between '$monthstart' and $monthend ) group by UserId";

By the way regarding list values, why the "world of pain"? Are you creating columns all over the place? You probably know it, but CGI.pm can freeze into a string joined by nulls. Not that DBI might like it any.

Hope this helps.


In reply to Re: DBI quoting when I don't want it to by mattr
in thread DBI quoting when I don't want it to by Tardis

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.