fixing postgres/sqlite month query