You could use some of the DateTime modules for this kind of thing (you'd need to do something a bit different to make the recurrence logic jump from one Wednesday to the next):
use strict; use DateTime::Set; use DateTime::Format::MySQL; my ($d1,$d2) = (DateTime->now(),DateTime->now()->add(days=>7)); my $set = DateTime::Set->from_recurrence( after => $d1, before => $d2, recurrence => sub { $_[0]->truncate(to=>'day')->add(days=>1) }, ); my @dates = map { DateTime::Format::MySQL->format_date($_) } $set->as_list; # @dates now contains a list of MySQL looking date strings
I've also done the same thing in the past by using MySQL's from_days() function. This "works" but is probably not recommended
# non-production-ready code follows my ($start_day,$end_day) = $dbh->selectrow_array("select to_days(now() +), to_days(now() + interval 7 day)"); my @dates = map { $dbh->selectrow_array("select from_days($_)") } $start_day .. $end_day;

In reply to Re: MySQL query question... by bpphillips
in thread MySQL query question... by Anonymous Monk

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.