[Ssh-sftp-perl-users] Comparing two dates (day) & Months
Brought to you by:
dbrobins
From: Perl P. <per...@gm...> - 2009-02-24 18:09:34
|
> > Dear All, > > I have to compare two dates. And populate the result based on > that. > First date I have received from previous script, which in this form > 5-Feb-09. > And I have to compare this date with current date, locatime() . With the > localtime() I will get the current Day (24),Month (2) & year (2009 ) > > I will split the old date as below and get the result as below. > > $Old_Day = 5; > $Old_Month = Feb. > > And then I convert Feb to 2 ( Month number ) by using scalar veriable. ( > The thing repeated for all months ). > > if( $Old_Month eq Feb) > { > $Old_Month = "2"; > } > elsif($Old_Month eq Mar ) > { > $Old_Month = "3"; > } > ..... > elsif($Old_Month eq Dec ) > { > $Old_Month = "13"; > } > > And in current month, which I got from localtime function as, > > $Current_Month , which will be 2 ( not sure this is a string or a numric > ). > > so while substracting or comparing as below, > > if (($current_Month - $Old_Month > 10) ) > { > print " Some operation "; > } > > Here if I compare with current month with the old_month (Feb) then the > result is fine. > but if the old_month is something like Jan or Jun something, then I am not > getting the properl result. > > Please let me know how can I compare and Substract two months or two dates > in above scenario. > > Thanks a lot for your kind help. > > Regards, > Mujju > > |