diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php
index 3b9ad9ac3e4760cb832b93106cb401a0cdad55aa..89f2a66bdea86f61aca20db48bb3d74349ff9f3e 100644
--- a/htdocs/core/db/pgsql.class.php
+++ b/htdocs/core/db/pgsql.class.php
@@ -412,8 +412,8 @@ class DoliDBPgsql extends DoliDB
 		{
 			$this->database_name = $name;
 			pg_set_error_verbosity($this->db, PGSQL_ERRORS_VERBOSE);	// Set verbosity to max
+			pg_query($this->db, "set datestyle = 'ISO, YMD';");
 		}
-		pg_query($this->db, "set datestyle = 'ISO, YMD';");
 
 		return $this->db;
 	}