diff --git a/database/core.tsql b/database/core.tsql
index 4ee376046b9b00280bea84348d870cdad3dad8a9..e69c7d8c750222e1708b8bef6cc906fe7545509f 100644
--- a/database/core.tsql
+++ b/database/core.tsql
@@ -142,7 +142,7 @@ CREATE TABLE @PREFIX@topups_summary (
 
 	TopupID			@SERIAL_REF_TYPE@ NOT NULL,
 
-	PeriodKey		DATETIME, 
+	PeriodKey		VARCHAR(255) NOT NULL, 
 
 	Balance			@INT_UNSIGNED@,
 
diff --git a/smradius/modules/config/mod_config_sql_topups.pm b/smradius/modules/config/mod_config_sql_topups.pm
index fa487a203ef3dae556808d978f38a232f068a053..31cafeb5b30efcaacaab4a04ec1b596a3bd5adaa 100644
--- a/smradius/modules/config/mod_config_sql_topups.pm
+++ b/smradius/modules/config/mod_config_sql_topups.pm
@@ -394,7 +394,7 @@ sub cleanup
 							VALUES
 								(?,?,?)
 							',
-							$topup->{'ID'},$thisMonth,$trafficRemaining
+							$topup->{'ID'},$thisMonth->year."-".$thisMonth->month,$trafficRemaining
 						);
 						if (!$sth) {
 							$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to update topup summary: ".
@@ -432,7 +432,7 @@ sub cleanup
 							VALUES
 								(?,?,?)
 							',
-							$topup->{'ID'},$thisMonth,$uptimeRemaining
+							$topup->{'ID'},$thisMonth->year."-".$thisMonth->month,$uptimeRemaining
 						);
 						if (!$sth) {
 							$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to update topups: ".