Here is the code rewritten a bit. I would probably use CGI to generate the drop down, but this should give you an idea. I use $x as the offset and loop over it unshift (push but on the other end of the array so i don't have to reverse). This way you can do 0-45 and get exactly what you want. BTW This code does 45 days (excluding weekends), not the last 45 work days.

#!/perl/bin/perl use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use Date::Calc qw(Add_Delta_Days Day_of_Week); use strict; # DATE DROPDOWN (last 30 business days) common wherever found my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); $mon++; $year += 1900; my (@date_dd_from,@date_dd_to); #Sample dates my $selected_date_from = "1/23/2008"; my $selected_date_to = "1/23/2008"; for my $x (0..45) { # 45 days later my ($n_year,$n_mon,$n_mday) = Add_Delta_Days($year,$mon,$mday,$x) +; if (Day_of_Week($n_year,$n_mon,$n_mday) < 6) { my $date = "$n_mon/$n_mday/$n_year"; my $from_selected = $date eq $selected_date_from ? 'selected' + : ''; my $to_selected = $date eq $selected_date_to ? 'selected' + : ''; unshift @date_dd_from, "<option $from_selected value='$date'>$dat +e</option>\n"; unshift @date_dd_to, "<option $to_selected value='$date'> +$date</option>\n"; } } print "\n", @date_dd_to, "\n";

___________
Eric Hodges

In reply to Re^2: Getting the Latest Date Issue by eric256
in thread Getting the Latest Date Issue 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.