How do you define "previous" in "previous business week"? I'm going to assume you want the last M-F in which the current day is not a member.
use strict; use warnings; use DateTime qw( ); use Text::CSV_XS qw( ); my $today = DateTime->today( time_zone => 'local' ); my $dow = $today->dow(); my $last_fri = $today->subtract( days => ( $dow <= 5 ? $dow-5+7 : $dow-5 ) ); my $last_mon = $last_fri->subtract( days => 4, ); my $start = $last_fri->strftime("%Y%m%d00"); my $end = $last_mon->strftime("%Y%m%d99"); my $csv = Text::CSV_XS->new(); while (<$fh_in>) { $csv->parse($_) or die("csv: " . $csv->error_diag() . "\n"); my ($ts) = $csv->fields(); next if $ts lt $start || $ts gt $end; print $fh_out $_; }
In reply to Re: Extract data between certain dates using YYYYMMDDHH timestamp
by ikegami
in thread Extract data between certain dates using YYYYMMDDHH timestamp
by chud83
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |