Skip to content

Instantly share code, notes, and snippets.

@sinkovsky
Created December 27, 2010 12:58
Show Gist options
  • Save sinkovsky/756110 to your computer and use it in GitHub Desktop.
Save sinkovsky/756110 to your computer and use it in GitHub Desktop.
my $next_date = $report->{start_date};
my $interval = '';
if ( $report->{reccurence} eq 'daily' ) {
$interval = 'DAY';
} elsif ( $report->{reccurence} eq 'weekly' ) {
$interval = 'WEEK';
} else {
$interval = 'MONTH';
}
my $date = $dbh->selectrow_hashref("SELECT DATE(?) < DATE(NOW()) AS lesser", undef, $next_date);
while ( $date->{lesser} ) {
my $tmp = $dbh->selectrow_hashref("SELECT DATE(?) + INTERVAL 1 $interval AS next_date", undef, $next_date);
$next_date = $tmp->{next_date};
$date = $dbh->selectrow_hashref("SELECT DATE(?) < DATE(NOW()) AS lesser", undef, $next_date);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment