Re: [Ssh-sftp-perl-users] Comparing two dates (day) & Months
Brought to you by:
dbrobins
|
From: Ken B. <ken...@co...> - 2009-03-11 01:03:59
|
You do know that you can read both dates into a gmtime structure and do
everything in there.
-----Original Message-----
From: Nigel Reed [mailto:ni...@sy...]
Sent: Tuesday, February 24, 2009 13:49
To: Perl Perl
Cc: ssh...@li...
Subject: Re: [Ssh-sftp-perl-users] Comparing two dates (day) & Months
Three suggestions.
1) Use the Date::Calc module
2) Post to a list for general PERL questions, not one for Net::SSH::Perl
3) Pick up a copy of Perl Programming
Oh, here's a free one, Dec is the 12th month.
%mon2num = qw(
Jan 1 Feb 2 Mar 3 Apr 4 May 5 Jun 6 Jul 7 Aug 8 Sep 9 Oct 10
Nov 11 Dec 12
);
$monthtext="Feb";
$monthnum = $mon2num{"$monthtext"};
Perl Perl wrote:
>>
>> 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
>>
>>
>
----------------------------------------------------------------------------
--
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
> CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
> Enterprise
> -Strategies to boost innovation and cut costs with open source
> participation
> -Receive a $600 discount off the registration fee with the source code:
> SFAD
>
http://p.sf.net/sfu/XcvMzF8H_______________________________________________
> Ssh-sftp-perl-users mailing list
> Ssh...@li...
> https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users
>
--
Nigel Reed
Candidate for Lieutenant Governor of Marketing 2009-2010
President & CEO Sysadmin, Inc
972 673 4199 http://www.sysadmininc.com
Toastmasters District 50 Vista Division Governor 2008-2009
Awareness, Attitude and Action bring Achievement!
|