-my $sdate = $cgi->param('start_year').
- '-'.
- $cgi->param('start_month').
- '-01';
-my $edate = ($cgi->param('end_year') +
- ($cgi->param('end_month')==12)).
- '-'.
- ($cgi->param('end_month') % 12 + 1).
- '-01'; # first day of the next month
-
-my $sql = "AND signupdate >= ".str2time($sdate).
- " AND signupdate < ".str2time($edate);
-
-foreach my $cust (qsearch({ table => 'cust_main',
+
+my $sdate = DateTime->new(
+ year => scalar($cgi->param('start_year')),
+ month => scalar($cgi->param('start_month')),
+)->epoch();
+
+my $edate = DateTime->new(
+ year => scalar($cgi->param('end_year')),
+ month => scalar($cgi->param('end_month')),
+)->add( months => 1 )->epoch();
+
+my $where = (%where ? ' AND ' : ' WHERE ');
+$where .= " signupdate >= $sdate ".
+ " AND signupdate < $edate ";
+
+foreach my $cust (qsearch({ table => 'cust_main',