diff --git a/res/res_odbc.c b/res/res_odbc.c
index f97a198632d9cf5d3a1d18fd63553ae83eefee8e..201cf77b938bdc802684a649a0c0a6f0b437dd1f 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -516,7 +516,7 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
 
 	if (obj && check) {
 		ast_odbc_sanity_check(obj);
-	} else if (obj->parent->idlecheck > 0 && ast_tvdiff_ms(ast_tvnow(), obj->last_used) / 1000 > obj->parent->idlecheck)
+	} else if (obj && obj->parent->idlecheck > 0 && ast_tvdiff_sec(ast_tvnow(), obj->last_used) > obj->parent->idlecheck)
 		odbc_obj_connect(obj);
 
 	return obj;