Hi guys
I have to validate that one date is withinrange of two different dates.
For instance:
DateToCheck = 2008-03-27
InitialDate= 2008-03-23
FinalDate = 2008- 03-28
In this case above, the result will be ok, datetocheck is within range.
Now, I have found that Date::Manip module can do the job,
Actually this routine compare 2 dates and it works good for me.
Now, my problem start when I want to compare one specified date ($ms_date) against two dates ($date1 and $date2) (check if $ms_date is within range).
Look at it, maybe it's because it's Friday :-( and I am thinking too much about the weekend..
What's wrong here?? Advices
dmazzini
GSM/UMTS System and Telecomm Consultant
I have to validate that one date is withinrange of two different dates.
For instance:
DateToCheck = 2008-03-27
InitialDate= 2008-03-23
FinalDate = 2008- 03-28
In this case above, the result will be ok, datetocheck is within range.
Now, I have found that Date::Manip module can do the job,
Actually this routine compare 2 dates and it works good for me.
Code:
sub run{
if (! $date1) {
Win32::MsgBox("Date 1 is missing please add a Date",0,'REPORTMX');
redo;
}
if (! $date2) {
Win32::MsgBox("Date 2 is missing please add a Date",0,'REPORTMX');
redo;
}
$date1 = ParseDate($date1);
$date2 = ParseDate($date2);
$flag = Date_Cmp($date1,$date2);
if ($flag>0) {
Win32::MsgBox("Date 2 is earlier than Date 1. Invalid Option",0,'REPORTMX');
redo;
}
if ($flag<0) {
Win32::MsgBox("Date 1 is earlier than Date 2",0,'REPORTMX');
redo;
} elsif ($flag==0) {
Win32::MsgBox("the two dates are identical",0,'REPORTMX');
redo;
} else {
Win32::MsgBox("Date 2 is earlier than Date 1",0,'REPORTMX');
redo;
}
}
Now, my problem start when I want to compare one specified date ($ms_date) against two dates ($date1 and $date2) (check if $ms_date is within range).
Look at it, maybe it's because it's Friday :-( and I am thinking too much about the weekend..
Code:
sub check_date_range{
$flag1 = Date_Cmp($ms_date,$date1);
if ($flag1<0) {
$date_within_range_1=1;
}
if ($flag1==0) {
$date_within_range_1=1;
}
$flag2 = Date_Cmp($ms_date,$date2);
if ($flag2<0 && $date_within_range_1==1) {
$date_within_range_2=1;
}
$ms_is_in_range=1 if ($date_within_range_1==1 && $date_within_range_2==1);
}
What's wrong here?? Advices
dmazzini
GSM/UMTS System and Telecomm Consultant