【发布时间】:2014-09-26 18:28:25
【问题描述】:
我有一份报告,每周在星期五运行一些数据库查询,其中数据是从星期一到星期五,并生成一个包含结果的表格。当报告在上个月星期一的星期五运行时,我遇到了问题。例如上周五。星期五是 8 月的第一天,星期一是 7 月 28 日。以下是我的脚本的日期和时间部分。
my $date = `date +%Y%m%d`;
chomp($date);
my $time = `date +%H%M%S`;
chomp($time);
my $day = `date +%A`;
chomp($day);
my $time = `date +%H%M%S`;
chomp($time);
my $dispTime = `date +%H:%M`;
chomp($dispTime);
# Set the Dates
my $end = $date;
my $start = $end;
# Check the day and define start and end dates.
if ($day eq "Friday") {
$start = $end - 5;
my @mytime=localtime;
my ($s, $min, $h, $d, $m, $y) = (0, 0, 0, $mytime[3], $mytime[4], $mytime[5]);
my $todayminus5 = strftime "%Y%m%d", $s, $min, $h, $d - 5, $m, $y;
$start = $todayminus5;
在我的报告日志中,它打印了计算的日期并打印了这个
Start Date = 2014080,
End Date = 20140801
有谁知道为什么这似乎无法计算超过两个月的日期?
【问题讨论】: