in reply to if && condition not working

Can you show us your data?

Replies are listed 'Best First'.
Re^2: if && condition not working
by Anonymous Monk on Mar 24, 2010 at 19:06 UTC
    A date in the future can have the same month and year as today. Tomorrow is a good example (assuming today is not the last day of the month or year).

      assuming today is not the last day of the month or year

      He doesn't handle that either, mind you.

Re^2: if && condition not working
by rakheek (Sexton) on Mar 24, 2010 at 19:06 UTC
    Thanks for replying Anonymous Monk. Yes, my data is right. I printed it out. Also, if I use if condition without the &&, it works. I am totally confused. Here is what worked:
    sub validate_date { my $start_date = $_[0]; my $end_date = $_[1]; my $today_date = $_[2]; my @start_date_array = split(/\//, $start_date); my @end_date_array = split(/\//, $end_date); my @today_date_array = split(/\//, $today_date); my $error_msg = ""; if (!$start_date || !$end_date){ $error_msg = "Blank Field in Date field. Please Use Browser Ba +ck button and Enter Date Field"}; # if ( (@start_date_array[0] > @today_date_array[0]) && (@start_ +date_array[1] > @today_date_array[1]) && (@start_date_array[2] > @tod +ay_date_array[2])) { if (@start_date_array[0] > @today_date_array[0]) { $error_msg = "Start Date can not be a Future Date. Please Use +Browser Back button and Enter Start Date"}; if ( (@end_date_array[0] > @today_date_array[0]) && (@end_date +_array[1] > @today_date_array[1]) && (@end_date_array[2] > @today_dat +e_array[2])) { $error_msg = "End Date can not be a Future Date. Please Use Br +owser Back button and Enter End Date"}; return $error_msg; }
      The request was not if your data is properly formatted. The request was to show us examples, so we know what to feed into the subroutine to test it. How are your dates formatted? Is it month/day/year, day/month/year, year/month/day? Is January represented by "1" or "01"? This information is very significant for showing you how your code is incorrect.