Suthakar P Maharajan wrote: > Is there anyway to find a number of days difference based on timestamp? > i have a file which has 'n' number of records with timestamp as > [2002-04-6] and i want to compare each record timstamp with today time > and if it is 30 days difference then delete those entries. > > Any suggestion will be appreciated. > > Thanks > Suthakar >
I am actually doing something very similar to this myself, which I just finished. I used the perl module Date-Calc5.0 on cpan.org that I found. There are a few functions that work great for this that are in there, use Date::Calc qw( Date_to_Days); use Date::Calc qw (Decode_Month); ( my month ws in 3 char format, JUL, JUN etc etc) First I took the local time and minus the seconds in a week, how long I only wanted to keep things.. my $cutoff_time = localtime(time-604800); in your case it would be...2592000 seconds i believe... ($junk,$mon1,$day1,$time,$year1) = split(/\s+/,$cutoff_time); $mon_num1 = Decode_Month($mon1); then get the second date stuff for the second part of the if statement, in your case, the record you are using.. if(Date_to_Days($year1,$mon_num1,$day1) > Date_to_Days($year2,$mon_num2,$day2)) { #delete here, since the record date is less than the month cutoff time specified above } I am sure there is an easier way to do this, but this is how I accomplished it :) Chris -- ------------------------------- Just Your Friendly Neighborhood _SPIDEY_
--------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/cgiapp@lists.vm.com/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]