use Class::Date qw/ date localdate now /; # date that the billing period starts (get data from db) my $period_start = date('2001-12-31'); # date to start attempting charges (get data from db) my $charge_date = date('2001-12-27'); my $today = date( localdate( now ))->truncate; # truncate makes time midnight # it's late if ( $charge_date < $today ){ print "Charge date passed. Transaction previously failed. Try again.\n"; } # not yet due elsif ( $charge_date > $today ) { print 'Charge to be processed in ', +( $charge_date - Class::Date->new( $today ) )->day, ' days.'; } # charge today else { print 'Today is charge date. If successful, next charge date will be: ', date( $charge_date + '1M'); # one month # change next charge date in BillSchedule table. }