Results 1 to 4 of 4
Is there any way to compare two dates in Perl ???...
- 03-04-2008 #1Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
Is there any way to compare two dates in Perl ???
Is there any way to compare two dates in Perl ???
Switched to Scripting
- 03-04-2008 #2Probably. How do you first come across these dates? As attributes of files? As strings? If as strings, what do the strings look like?Is there any way to compare two dates in Perl ?--
Bill
Old age and treachery will overcome youth and skill.
- 03-04-2008 #3Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
As a string see following, i know below one can not work but just for example what I am looking for:-
my $curr_date =`date +\%Y-\%m-\%d`;
chomp($curr_date);
if ($curr_date >= '2008-03-04') {
print "date is greater than/equal to current date";
} else { print "date is less than or check the date" ;}Switched to Scripting
- 03-04-2008 #4You wouldn't be explicitly comparing dates there, you'd be comparing strings, like two surnames in a phone book. But it works.Code:
if ($curr_date ge '2008-03-04')
--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote