diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php
index 955a33d1e5d070273fcd7b0f0edcb770608bb88e..ffb610747dbe21efdd2a8809c95af6ab0180267c 100644
--- a/htdocs/comm/fiche.php
+++ b/htdocs/comm/fiche.php
@@ -387,19 +387,19 @@ if ($socid > 0)
 	if ($conf->propal->enabled && $user->rights->propale->lire)
 	{
 		$propal_static = new Propal($db);
-		
+
 		$proposals = $propal_static->liste_array(0, 0, 0, $objsoc->id, $MAXLIST);
-		
+
 		//var_dump($proposals);
 
 		print '<table class="noborder" width="100%">';
 
 		$sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, ";
-		$sql.= " ".$db->pdate("p.datep")." as dp, ".$db->pdate("p.fin_validite")." as datelimite";
-		$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
-		$sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
-		$sql .= " AND s.rowid = ".$objsoc->id;
-		$sql .= " ORDER BY p.datep DESC";
+		$sql.= " p.datep as dp, p.fin_validite as datelimite";
+		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
+		$sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
+		$sql.= " AND s.rowid = ".$objsoc->id;
+		$sql.= " ORDER BY p.datep DESC";
 
 		$resql=$db->query($sql);
 		if ($resql)
@@ -419,11 +419,11 @@ if ($socid > 0)
 				$objp = $db->fetch_object($resql);
 				print "<tr $bc[$var]>";
 				print "<td nowrap><a href=\"propal.php?propalid=$objp->propalid\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."</a>\n";
-				if ( ($objp->dp < $now - $conf->propal->cloture->warning_delay) && $objp->fk_statut == 1 )
+				if ( ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1 )
 				{
 					print " ".img_warning();
 				}
-				print '</td><td align="right" width="80">'.dol_print_date($objp->dp,'day')."</td>\n";
+				print '</td><td align="right" width="80">'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
 				print '<td align="right" width="120">'.price($objp->total_ht).'</td>';
 				print '<td align="right" nowrap="nowrap">'.$propal_static->LibStatut($objp->fk_statut,5).'</td></tr>';
 				$var=!$var;
@@ -449,7 +449,7 @@ if ($socid > 0)
 
 		$sql = "SELECT s.nom, s.rowid,";
 		$sql.= " c.rowid as cid, c.total_ht, c.ref, c.fk_statut, c.facture,";
-		$sql.= " ".$db->pdate("c.date_commande")." as dc";
+		$sql.= " c.date_commande as dc";
 		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
 		$sql.= " WHERE c.fk_soc = s.rowid ";
 		$sql.= " AND s.rowid = ".$objsoc->id;
@@ -473,7 +473,7 @@ if ($socid > 0)
 				$var=!$var;
 				print "<tr $bc[$var]>";
 				print '<td nowrap="nowrap"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$objp->cid.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$objp->ref."</a>\n";
-				print '</td><td align="right" width="80">'.dol_print_date($objp->dc,'day')."</td>\n";
+				print '</td><td align="right" width="80">'.dol_print_date($db->jdate($objp->dc),'day')."</td>\n";
 				print '<td align="right" width="120">'.price($objp->total_ht).'</td>';
 				print '<td align="right" width="100">'.$commande_static->LibStatut($objp->fk_statut,$objp->facture,5).'</td></tr>';
 				$i++;
@@ -496,7 +496,7 @@ if ($socid > 0)
 
 		print '<table class="noborder" width="100%">';
 
-		$sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, ".$db->pdate("c.datec")." as dc";
+		$sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, c.datec as dc";
 		$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
 		$sql .= " WHERE c.fk_soc = s.rowid ";
 		$sql .= " AND s.rowid = ".$objsoc->id;
@@ -527,7 +527,7 @@ if ($socid > 0)
 				$contrat->ref=$objp->ref?$objp->ref:$objp->id;
 				print $contrat->getNomUrl(1,12);
 				print "</td>\n";
-				print '<td align="right" width="80">'.dol_print_date($objp->dc,'day')."</td>\n";
+				print '<td align="right" width="80">'.dol_print_date($db->jdate($objp->dc),'day')."</td>\n";
 				print '<td width="20">&nbsp;</td>';
 				print '<td align="right" nowrap="nowrap">';
 				$contrat->fetch_lignes();
@@ -552,7 +552,7 @@ if ($socid > 0)
 	{
 		print '<table class="noborder" width="100%">';
 
-		$sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, ".$db->pdate("f.datei")." as di";
+		$sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.datei as di";
 		$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f";
 		$sql .= " WHERE f.fk_soc = s.rowid";
 		$sql .= " AND s.rowid = ".$objsoc->id;
@@ -576,7 +576,7 @@ if ($socid > 0)
 				$objp = $db->fetch_object($resql);
 				print "<tr $bc[$var]>";
 				print '<td nowrap><a href="'.DOL_URL_ROOT.'/fichinter/fiche.php?id='.$objp->id.'">'.img_object($langs->trans("ShowPropal"),"propal").' '.$objp->ref.'</a>'."\n";
-				print '</td><td align="right">'.dol_print_date($objp->di,"day").'</td>'."\n";
+				print '</td><td align="right">'.dol_print_date($db->jdate($objp->di),"day").'</td>'."\n";
 				print '</tr>';
 				$var=!$var;
 				$i++;
@@ -598,7 +598,7 @@ if ($socid > 0)
 	{
 		print '<table class="noborder" width=100%>';
 
-		$sql  = "SELECT p.rowid,p.title,p.ref,p.public,".$db->pdate("p.dateo")." as do";
+		$sql  = "SELECT p.rowid,p.title,p.ref,p.public, p.dateo as do";
 		$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
 		$sql .= " WHERE p.fk_soc = $objsoc->id";
 		$sql .= " ORDER BY p.dateo DESC";
@@ -637,7 +637,7 @@ if ($socid > 0)
 						// Label
 						print '<td>'.$obj->title.'</td>';
 						// Date
-						print '<td align="right">'.dol_print_date($obj->do,"day").'</td>';
+						print '<td align="right">'.dol_print_date($db->jdate($obj->do),"day").'</td>';
 
 						print '</tr>';
 					}
@@ -669,19 +669,21 @@ if ($socid > 0)
 			//$num = sizeOf($result);
 			$num=$chronodocs_static->get_nb_chronodocs($objsoc->id);
 
-			if ($num > 0) {
+			if ($num > 0)
+			{
 				print '<tr class="liste_titre">';
 				print '<td colspan="3"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastChronodocs",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/chronodocs/index.php?socid='.$objsoc->id.'">'.$langs->trans("AllChronodocs").' ('.$num.')</td></tr></table></td>';
 				print '</tr>';
 			}
-			while ($i < $num && $i < $MAXLIST) {
+			while ($i < $num && $i < $MAXLIST)
+			{
 				$obj = array_shift($result);
 				$var = !$var;
 				print "<tr $bc[$var]>";
 				print '<td><a href="'.DOL_URL_ROOT.'/chronodocs/fiche.php?id='.$obj->fichid.'">'.img_object($langs->trans("ShowChronodocs"),"generic")." ".$obj->ref.'</a></td>';
 
 				print "<td align=\"left\">".dol_trunc($obj->title,30) ."</td>";
-				print "<td align=\"right\">".dol_print_date($obj->dp,'day')."</td>\n";
+				print "<td align=\"right\">".dol_print_date($db->jdate($obj->dp),'day')."</td>\n";
 				print "</tr>";
 
 				$i++;
diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php
index 7022e42aea4545bd7835a7c2a438543e5ccb70b3..c482c20c0e14e9b8aa1e0e6cfb5c558550b177fa 100644
--- a/htdocs/comm/index.php
+++ b/htdocs/comm/index.php
@@ -277,7 +277,7 @@ $max=3;
 
 if ($conf->propal->enabled && $user->rights->propale->lire)
 {
-	$sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.total_ht, p.ref, p.fk_statut, ".$db->pdate("p.datep")." as dp";
+	$sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.total_ht, p.ref, p.fk_statut, p.datep as dp";
 	$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
 	$sql.= ", ".MAIN_DB_PREFIX."propal as p";
 	if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -407,7 +407,7 @@ if ($conf->fournisseur->enabled && $user->rights->societe->lire)
 {
 	$langs->load("boxes");
 
-	$sql = "SELECT s.nom, s.rowid, ".$db->pdate("s.datec")." as dc";
+	$sql = "SELECT s.nom, s.rowid, s.datec as dc";
 	$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
 	if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
 	$sql.= " WHERE s.fournisseur = 1";
@@ -438,7 +438,7 @@ if ($conf->fournisseur->enabled && $user->rights->societe->lire)
 				$company->nom=$objp->nom;
 				print '<tr '.$bc[$var].'>';
 				print '<td nowrap="nowrap">'.$company->getNomUrl(1,'supplier',48).'</td>';
-				print '<td align="right">'.dol_print_date($objp->dc,'day').'</td>';
+				print '<td align="right">'.dol_print_date($db->jdate($objp->dc),'day').'</td>';
 				print '</tr>';
 				$var=!$var;
 				$i++;
@@ -533,7 +533,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
 {
 	$langs->load("propal");
 
-	$sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, ".$db->pdate("p.datep")." as dp";
+	$sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp";
 	$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
 	$sql.= ", ".MAIN_DB_PREFIX."propal as p";
 	if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -573,7 +573,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
 				print $propalstatic->getNomUrl(1);
 				print '</td>';
 				print '<td width="18" class="nobordernopadding" nowrap="nowrap">';
-				if ($obj->dp < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
+				if ($db->jdate($obj->dp) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
 				print '</td>';
 				print '<td width="16" align="center" class="nobordernopadding">';
 				$filename=dol_sanitizeFileName($obj->ref);
@@ -586,7 +586,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
 
 				print "<td align=\"left\"><a href=\"fiche.php?socid=".$obj->rowid."\">".img_object($langs->trans("ShowCompany"),"company")." ".dol_trunc($obj->nom,44)."</a></td>\n";
 				print "<td align=\"right\">";
-				print dol_print_date($obj->dp,'day')."</td>\n";
+				print dol_print_date($db->jdate($obj->dp),'day')."</td>\n";
 				print "<td align=\"right\">".price($obj->total_ttc)."</td>";
 				print "<td align=\"center\" width=\"14\">".$propalstatic->LibStatut($obj->fk_statut,3)."</td>\n";
 				print "</tr>\n";
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index cbf32d6e5f0c87475d0d20bd936f5facc1e9d63b..acfe240a46227434d68663d755af86a311ca3c66 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -1407,8 +1407,8 @@ if ($id > 0 || ! empty($ref))
 	$sql = 'SELECT pt.rowid, pt.description, pt.fk_product, pt.fk_remise_except,';
 	$sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,';
 	$sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.marge_tx, pt.marque_tx, pt.pa_ht, pt.special_code,';
-	$sql.= ' '.$db->pdate('pt.date_start').' as date_start,';
-	$sql.= ' '.$db->pdate('pt.date_end').' as date_end,';
+	$sql.= ' pt.date_start,';
+	$sql.= ' pt.date_end,';
 	$sql.= ' pt.product_type,';
 	$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
 	$sql.= ' p.description as product_desc';
@@ -1473,7 +1473,7 @@ if ($id > 0 || ! empty($ref))
 					print $html->textwithtooltip($text,$description,3,'','',$i);
 
 					// Show range
-					print_date_range($objp->date_start,$objp->date_end);
+					print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
 
 					// Add description in form
 					if ($conf->global->PRODUIT_DESC_IN_FORM)
@@ -1513,7 +1513,7 @@ if ($id > 0 || ! empty($ref))
 						print $text.' '.nl2br($objp->description);
 
 						// Show range
-						print_date_range($objp->date_start,$objp->date_end);
+						print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
 					}
 					print "</td>\n";
 				}
@@ -1716,18 +1716,7 @@ if ($id > 0 || ! empty($ref))
 				print '<td align="center" colspan="5" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
 				print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
 				print '</tr>' . "\n";
-				/*
-				 if ($conf->service->enabled)
-				 {
-				 print "<tr $bc[$var]>";
-				 print '<td colspan="5">Si produit de type service a duree limitee: Du ';
-				 print $html->select_date($objp->date_start,"date_start",0,0,$objp->date_start?0:1);
-				 print ' au ';
-				 print $html->select_date($objp->date_end,"date_end",0,0,$objp->date_end?0:1);
-				 print '</td>';
-				 print '</tr>' . "\n";
-				 }
-				 */
+
 				print "</form>\n";
 			}
 
diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php
index 8267289f558ad1122c069fae36db97b7c808f0f4..c5cbd23a51b58d41d10c50ca9c9f322dec30ce71 100644
--- a/htdocs/comm/remx.php
+++ b/htdocs/comm/remx.php
@@ -38,7 +38,7 @@ $langs->load("companies");
 $_socid = $_GET["id"];
 if ($user->societe_id > 0)
 {
-  $_socid = $user->societe_id;
+	$_socid = $user->societe_id;
 }
 
 
@@ -210,112 +210,112 @@ if ($_socid > 0)
 	dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"),0,'company');
 
 
-    print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$objsoc->id.'">';
-    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-    print '<input type="hidden" name="action" value="setremise">';
+	print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$objsoc->id.'">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print '<input type="hidden" name="action" value="setremise">';
 
-    print '<table class="border" width="100%">';
+	print '<table class="border" width="100%">';
 
-    // Name
+	// Name
 	print '<tr><td width="38%">'.$langs->trans('Name').'</td>';
 	print '<td>';
 	print $form->showrefnav($objsoc,'id','',1,'rowid','nom');
 	print '</td></tr>';
 
 	// Calcul avoirs en cours
-    $remise_all=$remise_user=0;
-    $sql = "SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
-    $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
-    $sql.= " WHERE rc.fk_soc =". $objsoc->id;
-    $sql.= " AND (fk_facture_line IS NULL AND fk_facture IS NULL)";
-    $sql.= " GROUP BY rc.fk_user";
-    $resql=$db->query($sql);
-    if ($resql)
-    {
-        $obj = $db->fetch_object($resql);
-        $remise_all+=$obj->amount;
-        if ($obj->fk_user == $user->id) $remise_user+=$obj->amount;
-    }
-    else
-    {
-    	dol_print_error($db);
-    }
-
-    print '<tr><td width="38%">'.$langs->trans("CustomerAbsoluteDiscountAllUsers").'</td>';
-    print '<td>'.$remise_all.'&nbsp;'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
-
-    print '<tr><td>'.$langs->trans("CustomerAbsoluteDiscountMy").'</td>';
-    print '<td>'.$remise_user.'&nbsp;'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
-    print '</table>';
+	$remise_all=$remise_user=0;
+	$sql = "SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
+	$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
+	$sql.= " WHERE rc.fk_soc =". $objsoc->id;
+	$sql.= " AND (fk_facture_line IS NULL AND fk_facture IS NULL)";
+	$sql.= " GROUP BY rc.fk_user";
+	$resql=$db->query($sql);
+	if ($resql)
+	{
+		$obj = $db->fetch_object($resql);
+		$remise_all+=$obj->amount;
+		if ($obj->fk_user == $user->id) $remise_user+=$obj->amount;
+	}
+	else
+	{
+		dol_print_error($db);
+	}
+
+	print '<tr><td width="38%">'.$langs->trans("CustomerAbsoluteDiscountAllUsers").'</td>';
+	print '<td>'.$remise_all.'&nbsp;'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
+
+	print '<tr><td>'.$langs->trans("CustomerAbsoluteDiscountMy").'</td>';
+	print '<td>'.$remise_user.'&nbsp;'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
+	print '</table>';
 	print '<br>';
 
 	print_fiche_titre($langs->trans("NewGlobalDiscount"),'','');
-    print '<table class="border" width="100%">';
-    print '<tr><td width="38%">'.$langs->trans("AmountHT").'</td>';
-    print '<td><input type="text" size="5" name="amount_ht" value="'.$_POST["amount_ht"].'">&nbsp;'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
-    print '<tr><td width="38%">'.$langs->trans("VAT").'</td>';
-    print '<td>';
+	print '<table class="border" width="100%">';
+	print '<tr><td width="38%">'.$langs->trans("AmountHT").'</td>';
+	print '<td><input type="text" size="5" name="amount_ht" value="'.$_POST["amount_ht"].'">&nbsp;'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
+	print '<tr><td width="38%">'.$langs->trans("VAT").'</td>';
+	print '<td>';
 	$form->select_tva('tva_tx','0','',$mysoc,'');
 	print '</td></tr>';
-    print '<tr><td>'.$langs->trans("NoteReason").'</td>';
-    print '<td><input type="text" size="60" name="desc" value="'.$_POST["desc"].'"></td></tr>';
+	print '<tr><td>'.$langs->trans("NoteReason").'</td>';
+	print '<td><input type="text" size="60" name="desc" value="'.$_POST["desc"].'"></td></tr>';
 
-    print '<tr><td align="center" colspan="2"><input type="submit" class="button" value="'.$langs->trans("AddGlobalDiscount").'"></td></tr>';
+	print '<tr><td align="center" colspan="2"><input type="submit" class="button" value="'.$langs->trans("AddGlobalDiscount").'"></td></tr>';
 
-    print "</table></form>";
+	print "</table></form>";
 
-    print "</div>\n";
+	print "</div>\n";
 
-    print '<br>';
+	print '<br>';
 
-    if ($_GET['action'] == 'remove')
-    {
+	if ($_GET['action'] == 'remove')
+	{
 		$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$objsoc->id.'&remid='.$_GET["remid"], $langs->trans('RemoveDiscount'), $langs->trans('ConfirmRemoveDiscount'), 'confirm_remove', '', 0, 1);
-    }
-
-    /*
-     * Liste remises fixes restant en cours (= liees a acune facture ni ligne de facture)
-     */
-    $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
-	$sql.= $db->pdate("rc.datec")." as dc, rc.description,";
-    $sql.= " rc.fk_facture_source,";
-    $sql.= " u.login, u.rowid as user_id,";
+	}
+
+	/*
+	 * Liste remises fixes restant en cours (= liees a acune facture ni ligne de facture)
+	 */
+	$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
+	$sql.= " rc.datec as dc, rc.description,";
+	$sql.= " rc.fk_facture_source,";
+	$sql.= " u.login, u.rowid as user_id,";
 	$sql.= " fa.facnumber as ref, fa.type as type";
-    $sql.= " FROM  ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc";
-    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
+	$sql.= " FROM  ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc";
+	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
 	$sql.= " WHERE rc.fk_soc =". $objsoc->id;
-    $sql.= " AND u.rowid = rc.fk_user";
+	$sql.= " AND u.rowid = rc.fk_user";
 	$sql.= " AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)";
-    $sql.= " ORDER BY rc.datec DESC";
-
-    $resql=$db->query($sql);
-    if ($resql)
-    {
-        print_titre($langs->trans("DiscountStillRemaining"));
-        print '<table width="100%" class="noborder">';
-        print '<tr class="liste_titre">';
-        print '<td width="120" align="left">'.$langs->trans("Date").'</td>';	// Need 120+ for format with AM/PM
-        print '<td width="150" align="left">'.$langs->trans("ReasonDiscount").'</td>';
-        print '<td align="left" nowrap="nowrap">'.$langs->trans("ConsumedBy").'</td>';
-        print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>';
-        print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>';
-        print '<td width="120" align="right">'.$langs->trans("AmountTTC").'</td>';
-        print '<td width="100" align="center">'.$langs->trans("DiscountOfferedBy").'</td>';
-        print '<td width="20">&nbsp;</td>';
-        print '</tr>';
-
-        $var = true;
-        $i = 0 ;
-        $num = $db->num_rows($resql);
-        while ($i < $num)
-        {
-            $obj = $db->fetch_object($resql);
-            $var = !$var;
-            print "<tr $bc[$var]>";
-            print '<td>'.dol_print_date($obj->dc,'dayhour').'</td>';
+	$sql.= " ORDER BY rc.datec DESC";
+
+	$resql=$db->query($sql);
+	if ($resql)
+	{
+		print_titre($langs->trans("DiscountStillRemaining"));
+		print '<table width="100%" class="noborder">';
+		print '<tr class="liste_titre">';
+		print '<td width="120" align="left">'.$langs->trans("Date").'</td>';	// Need 120+ for format with AM/PM
+		print '<td width="150" align="left">'.$langs->trans("ReasonDiscount").'</td>';
+		print '<td align="left" nowrap="nowrap">'.$langs->trans("ConsumedBy").'</td>';
+		print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>';
+		print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>';
+		print '<td width="120" align="right">'.$langs->trans("AmountTTC").'</td>';
+		print '<td width="100" align="center">'.$langs->trans("DiscountOfferedBy").'</td>';
+		print '<td width="20">&nbsp;</td>';
+		print '</tr>';
+
+		$var = true;
+		$i = 0 ;
+		$num = $db->num_rows($resql);
+		while ($i < $num)
+		{
+			$obj = $db->fetch_object($resql);
+			$var = !$var;
+			print "<tr $bc[$var]>";
+			print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
 			if ($obj->description == '(CREDIT_NOTE)')
 			{
-            	print '<td nowrap="nowrap">';
+				print '<td nowrap="nowrap">';
 				$facturestatic->id=$obj->fk_facture_source;
 				$facturestatic->ref=$obj->ref;
 				$facturestatic->type=$obj->type;
@@ -324,7 +324,7 @@ if ($_socid > 0)
 			}
 			elseif ($obj->description == '(DEPOSIT)')
 			{
-            	print '<td nowrap="nowrap">';
+				print '<td nowrap="nowrap">';
 				$facturestatic->id=$obj->fk_facture_source;
 				$facturestatic->ref=$obj->ref;
 				$facturestatic->type=$obj->type;
@@ -333,15 +333,15 @@ if ($_socid > 0)
 			}
 			else
 			{
-            	print '<td>';
+				print '<td>';
 				print $obj->description;
 				print '</td>';
 			}
-            print '<td align="left" nowrap="nowrap">'.$langs->trans("NotConsumed").'</td>';
+			print '<td align="left" nowrap="nowrap">'.$langs->trans("NotConsumed").'</td>';
 			print '<td align="right">'.price($obj->amount_ht).'</td>';
-            print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
-            print '<td align="right">'.price($obj->amount_ttc).'</td>';
-            print '<td align="center">';
+			print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
+			print '<td align="right">'.price($obj->amount_ttc).'</td>';
+			print '<td align="center">';
 			print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a>';
 			print '</td>';
 			if ($user->rights->societe->creer || $user->rights->facture->creer)
@@ -352,11 +352,11 @@ if ($_socid > 0)
 				print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$objsoc->id.'&amp;action=remove&amp;remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).'</a>';
 				print '</td>';
 			}
-            else print '<td>&nbsp;</td>';
-            print '</tr>';
+			else print '<td>&nbsp;</td>';
+			print '</tr>';
 
-            if ($_GET["action"]=='split' && $_GET['remid'] == $obj->rowid)
-            {
+			if ($_GET["action"]=='split' && $_GET['remid'] == $obj->rowid)
+			{
 				print "<tr $bc[$var]>";
 				print '<td colspan="8">';
 				$amount1=price2num($obj->amount_ttc/2,'MT');
@@ -370,109 +370,109 @@ if ($_socid > 0)
 				$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$objsoc->id.'&remid='.$obj->rowid, $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount',price($obj->amount_ttc),$langs->transnoentities("Currency".$conf->monnaie)), 'confirm_split', $formquestion, 0, 0);
 				print '</td>';
 				print '</tr>';
-            }
-            $i++;
-        }
-        $db->free($resql);
-        print "</table>";
-    }
-    else
-    {
-    	dol_print_error($db);
-    }
-
-    print '<br>';
-
-    /*
-     * Liste ristournes appliquees (=liees a une ligne de facture ou facture)
-     */
-
-    // Remises liees a lignes de factures
-    $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
-	$sql.= $db->pdate("rc.datec")." as dc, rc.description, rc.fk_facture_line, rc.fk_facture,";
-    $sql.= " rc.fk_facture_source,";
+			}
+			$i++;
+		}
+		$db->free($resql);
+		print "</table>";
+	}
+	else
+	{
+		dol_print_error($db);
+	}
+
+	print '<br>';
+
+	/*
+	 * Liste ristournes appliquees (=liees a une ligne de facture ou facture)
+	 */
+
+	// Remises liees a lignes de factures
+	$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
+	$sql.= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,";
+	$sql.= " rc.fk_facture_source,";
 	$sql.= " u.login, u.rowid as user_id,";
-    $sql.= " f.rowid, f.facnumber,";
+	$sql.= " f.rowid, f.facnumber,";
 	$sql.= " fa.facnumber as ref, fa.type as type";
-    $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
-    $sql.= " , ".MAIN_DB_PREFIX."user as u";
-    $sql.= " , ".MAIN_DB_PREFIX."facturedet as fc";
-    $sql.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
-    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
-    $sql.= " WHERE rc.fk_soc =". $objsoc->id;
-    $sql.= " AND rc.fk_facture_line = fc.rowid";
-    $sql.= " AND fc.fk_facture = f.rowid";
-    $sql.= " AND rc.fk_user = u.rowid";
+	$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
+	$sql.= " , ".MAIN_DB_PREFIX."user as u";
+	$sql.= " , ".MAIN_DB_PREFIX."facturedet as fc";
+	$sql.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
+	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
+	$sql.= " WHERE rc.fk_soc =". $objsoc->id;
+	$sql.= " AND rc.fk_facture_line = fc.rowid";
+	$sql.= " AND fc.fk_facture = f.rowid";
+	$sql.= " AND rc.fk_user = u.rowid";
 	$sql.= " ORDER BY dc DESC";
 	//$sql.= " UNION ";
-    // Remises liees a factures
-	$sql2= "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
-	$sql2.= $db->pdate("rc.datec")." as dc, rc.description, rc.fk_facture_line, rc.fk_facture,";
-    $sql2.= " rc.fk_facture_source,";
+	// Remises liees a factures
+	$sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
+	$sql2.= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,";
+	$sql2.= " rc.fk_facture_source,";
 	$sql2.= " u.login, u.rowid as user_id,";
-    $sql2.= " f.rowid, f.facnumber,";
+	$sql2.= " f.rowid, f.facnumber,";
 	$sql2.= " fa.facnumber as ref, fa.type as type";
-    $sql2.= " FROM ".MAIN_DB_PREFIX."facture as f";
-    $sql2.= " , ".MAIN_DB_PREFIX."user as u";
-    $sql2.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
-    $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
-    $sql2.= " WHERE rc.fk_soc =". $objsoc->id;
-    $sql2.= " AND rc.fk_facture = f.rowid";
-    $sql2.= " AND rc.fk_user = u.rowid";
+	$sql2.= " FROM ".MAIN_DB_PREFIX."facture as f";
+	$sql2.= " , ".MAIN_DB_PREFIX."user as u";
+	$sql2.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
+	$sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
+	$sql2.= " WHERE rc.fk_soc =". $objsoc->id;
+	$sql2.= " AND rc.fk_facture = f.rowid";
+	$sql2.= " AND rc.fk_user = u.rowid";
 
 	$sql2.= " ORDER BY dc DESC";
 
-    $resql=$db->query($sql);
+	$resql=$db->query($sql);
 	$resql2=null;
-    if ($resql) $resql2=$db->query($sql2);
+	if ($resql) $resql2=$db->query($sql2);
 	if ($resql2)
-    {
-        print_titre($langs->trans("DiscountAlreadyCounted"));
-        print '<table class="noborder" width="100%">';
-        print '<tr class="liste_titre">';
-        print '<td width="120" align="left">'.$langs->trans("Date").'</td>';	// Need 120+ for format with AM/PM
-        print '<td width="150" align="left">'.$langs->trans("ReasonDiscount").'</td>';
-        print '<td align="left" nowrap="nowrap">'.$langs->trans("ConsumedBy").'</td>';
-        print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>';
-        print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>';
-        print '<td width="120" align="right">'.$langs->trans("AmountTTC").'</td>';
-        print '<td width="100" align="center">'.$langs->trans("Author").'</td>';
-        print '<td width="20">&nbsp;</td>';
-        print '</tr>';
-
-        $var = true;
+	{
+		print_titre($langs->trans("DiscountAlreadyCounted"));
+		print '<table class="noborder" width="100%">';
+		print '<tr class="liste_titre">';
+		print '<td width="120" align="left">'.$langs->trans("Date").'</td>';	// Need 120+ for format with AM/PM
+		print '<td width="150" align="left">'.$langs->trans("ReasonDiscount").'</td>';
+		print '<td align="left" nowrap="nowrap">'.$langs->trans("ConsumedBy").'</td>';
+		print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>';
+		print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>';
+		print '<td width="120" align="right">'.$langs->trans("AmountTTC").'</td>';
+		print '<td width="100" align="center">'.$langs->trans("Author").'</td>';
+		print '<td width="20">&nbsp;</td>';
+		print '</tr>';
+
+		$var = true;
 		$tab_sqlobj=array();
 		$tab_sqlobjOrder=array();
-        $num = $db->num_rows($resql);
+		$num = $db->num_rows($resql);
 		for ($i = 0;$i < $num;$i++)
-			{
+		{
 			$sqlobj = $db->fetch_object($resql);
 			$tab_sqlobj[] = $sqlobj;
-			$tab_sqlobjOrder[]=$sqlobj->dc;
-			}
+			$tab_sqlobjOrder[]=$db->jdate($sqlobj->dc);
+		}
 		$db->free($resql);
 
 		$num = $db->num_rows($resql2);
 		for ($i = 0;$i < $num;$i++)
-			{
+		{
 			$sqlobj = $db->fetch_object($resql2);
 			$tab_sqlobj[] = $sqlobj;
-			$tab_sqlobjOrder[]= $sqlobj->dc;
-			}
+			$tab_sqlobjOrder[]= $db->jdate($sqlobj->dc);
+		}
 		$db->free($resql2);
 		array_multisort ($tab_sqlobjOrder,SORT_DESC,$tab_sqlobj);
 
 		$num = sizeOf($tab_sqlobj);
 		$i = 0 ;
-        while ($i < $num )
-        {
-            $obj = array_shift($tab_sqlobj);
-            $var = !$var;
-            print "<tr $bc[$var]>";
-            print '<td>'.dol_print_date($obj->dc,'dayhour').'</td>';
+		while ($i < $num )
+		{
+			$obj = array_shift($tab_sqlobj);
+			$var = !$var;
+			print "<tr $bc[$var]>";
+			print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
 			if ($obj->description == '(CREDIT_NOTE)')
 			{
-            	print '<td nowrap="nowrap">';
+				print '<td nowrap="nowrap">';
 				$facturestatic->id=$obj->fk_facture_source;
 				$facturestatic->ref=$obj->ref;
 				$facturestatic->type=$obj->type;
@@ -481,7 +481,7 @@ if ($_socid > 0)
 			}
 			elseif ($obj->description == '(DEPOSIT)')
 			{
-            	print '<td nowrap="nowrap">';
+				print '<td nowrap="nowrap">';
 				$facturestatic->id=$obj->fk_facture_source;
 				$facturestatic->ref=$obj->ref;
 				$facturestatic->type=$obj->type;
@@ -490,27 +490,27 @@ if ($_socid > 0)
 			}
 			else
 			{
-            	print '<td>';
+				print '<td>';
 				print $obj->description;
 				print '</td>';
 			}
-            print '<td align="left" nowrap="nowrap"><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.'</a></td>';
-            print '<td align="right">'.price($obj->amount_ht).'</td>';
-            print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
-            print '<td align="right">'.price($obj->amount_ttc).'</td>';
-            print '<td align="center">';
+			print '<td align="left" nowrap="nowrap"><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.'</a></td>';
+			print '<td align="right">'.price($obj->amount_ht).'</td>';
+			print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
+			print '<td align="right">'.price($obj->amount_ttc).'</td>';
+			print '<td align="center">';
 			print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a>';
 			print '</td>';
-            print '<td>&nbsp;</td>';
-            print '</tr>';
-            $i++;
-        }
-        print "</table>";
-    }
-    else
-    {
-        print dol_print_error($db);
-    }
+			print '<td>&nbsp;</td>';
+			print '</tr>';
+			$i++;
+		}
+		print "</table>";
+	}
+	else
+	{
+		print dol_print_error($db);
+	}
 
 }
 
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 4f294cf9913c1dce939f3be0a1f00d9de808e0b2..79506be4a6530a827d4135869d80309e6f6917a1 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -1033,7 +1033,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
 	{
 		$sql = 'SELECT s.nom, s.prefix_comm, s.rowid';
 		$sql.= ', p.price, p.remise, p.remise_percent, p.tva, p.total, p.ref, p.fk_cond_reglement, p.fk_mode_reglement';
-		$sql.= ', '.$db->pdate('p.datep').' as dp';
+		$sql.= ', p.datep as dp';
 		$sql.= ', c.id as statut, c.label as lst';
 		$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c';
 		$sql .= ' WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id';
@@ -1693,8 +1693,8 @@ else
 			$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.description, l.price, l.qty, l.tva_tx, ';
 			$sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.info_bits,';
 			$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
-			$sql.= ' '.$db->pdate('l.date_start').' as date_start,';
-			$sql.= ' '.$db->pdate('l.date_end').' as date_end,';
+			$sql.= ' l.date_start,';
+			$sql.= ' l.date_end,';
 			$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, ';
 			$sql.= ' p.description as product_desc';
 			$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
@@ -1754,7 +1754,7 @@ else
 							print $html->textwithtooltip($text,$description,3,'','',$i);
 
 							// Show range
-							print_date_range($objp->date_start,$objp->date_end);
+							print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
 
 							// Add description in form
 							if ($conf->global->PRODUIT_DESC_IN_FORM)
@@ -1795,7 +1795,7 @@ else
 								print $text.' '.nl2br($objp->description);
 
 								// Show range
-								print_date_range($objp->date_start,$objp->date_end);
+								print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
 							}
 							print '</td>';
 						}
@@ -1944,9 +1944,9 @@ else
 						// Start and end dates selector
 						print '<tr '.$bc[$var].'>';
 						print '<td colspan="9">'.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
-						print $html->select_date($objp->date_start,'date_start',$usehm,$usehm,$objp->date_start?0:1,"updateligne");
+						print $html->select_date($db->jdate($objp->date_start),'date_start',$usehm,$usehm,$objp->date_start?0:1,"updateligne");
 						print ' '.$langs->trans('to').' ';
-						print $html->select_date($objp->date_end,'date_end',$usehm,$usehm,$objp->date_end?0:1,"updateligne");
+						print $html->select_date($db->jdate($objp->date_end),'date_end',$usehm,$usehm,$objp->date_end?0:1,"updateligne");
 						print '</td>';
 						print '</tr>';
 
diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php
index b5a6fbb6128fb3417432b4244e12bb413289cb47..d4dd8445e122415c2b1aa1bbdd180b4d482222a1 100644
--- a/htdocs/compta/bank/releve.php
+++ b/htdocs/compta/bank/releve.php
@@ -254,7 +254,7 @@ else
 	}
 
 	// Recherche les ecritures pour le releve
-	$sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do,".$db->pdate("b.datev")." as dv";
+	$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv";
 	$sql.= ", b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type";
 	$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
 	$sql.= " WHERE b.num_releve='".$num."'";
@@ -283,13 +283,13 @@ else
 			print "<tr $bc[$var]>";
 
 			// Date operation
-			print '<td nowrap="nowrap" align="center">'.dol_print_date($objp->do,"day").'</td>';
+			print '<td nowrap="nowrap" align="center">'.dol_print_date($db->jdate($objp->do),"day").'</td>';
 
 			// Date de valeur
 			print '<td align="center" valign="center" nowrap="nowrap">';
 			print '<a href="releve.php?action=dvprev&amp;num='.$num.'&amp;account='.$_GET["account"].'&amp;dvid='.$objp->rowid.'">';
 			print img_previous().'</a> ';
-			print dol_print_date($objp->dv,"day") .' ';
+			print dol_print_date($db->jdate($objp->dv),"day") .' ';
 			print '<a href="releve.php?action=dvnext&amp;num='.$num.'&amp;account='.$_GET["account"].'&amp;dvid='.$objp->rowid.'">';
 			print img_next().'</a>';
 			print "</td>\n";
diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php
index f0c761126aeea2343e649f48319b2f38bd91faff..875cfcbabe8c80105c2682ad556a67035377a399 100644
--- a/htdocs/compta/bank/treso.php
+++ b/htdocs/compta/bank/treso.php
@@ -152,7 +152,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
 	// Remainder to pay in future
 
 	// Customer invoices
-	$sql = "SELECT 'invoice' as family, f.rowid as objid, f.facnumber as ref, f.total_ttc, f.type, ".$db->pdate("f.date_lim_reglement")." as dlr,";
+	$sql = "SELECT 'invoice' as family, f.rowid as objid, f.facnumber as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,";
 	$sql.= " s.rowid as socid, s.nom, s.fournisseur";
 	$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
 	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
@@ -161,7 +161,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
 	$sql.= " ORDER BY dlr ASC";
 
 	// Supplier invoices
-	$sql2= " SELECT 'supplier_invoice' as family, ff.rowid as objid, ff.facnumber as ref, (-1*ff.total_ttc) as total_ttc, ff.type, ".$db->pdate("ff.date_lim_reglement")." as dlr,";
+	$sql2= " SELECT 'supplier_invoice' as family, ff.rowid as objid, ff.facnumber as ref, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,";
 	$sql2.= " s.rowid as socid, s.nom, s.fournisseur";
 	$sql2.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff";
 	$sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid";
@@ -170,7 +170,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
 	$sql2.= " ORDER BY dlr ASC";
 
 	// Social contributions
-	$sql3= " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, ".$db->pdate("cs.date_ech")." as dlr";
+	$sql3= " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr";
 	$sql3.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs";
 	$sql3.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id";
 	$sql3.= " WHERE cs.entity = ".$conf->entity;
@@ -190,7 +190,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
 		{
 			$sqlobj = $db->fetch_object($result);
 			$tab_sqlobj[] = $sqlobj;
-			$tab_sqlobjOrder[]= $sqlobj->dlr;
+			$tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr);
 		}
 		$db->free($result);
 	}
@@ -205,7 +205,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
 		{
 			$sqlobj = $db->fetch_object($result2);
 			$tab_sqlobj[] = $sqlobj;
-			$tab_sqlobjOrder[]= $sqlobj->dlr;
+			$tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr);
 		}
 		$db->free($result2);
 	}
@@ -221,7 +221,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
 		{
 			$sqlobj = $db->fetch_object($result3);
 			$tab_sqlobj[] = $sqlobj;
-			$tab_sqlobjOrder[]= $sqlobj->dlr;
+			$tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr);
 		}
 		$db->free($result3);
 	}
@@ -303,7 +303,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
 			$solde += $total_ttc;
 
 			print "<tr $bc[$var]>";
-			print '<td>'.dol_print_date($obj->dlr,"day")."</td>";
+			print '<td>'.dol_print_date($db->jdate($obj->dlr),"day")."</td>";
 			print "<td>".$ref."</td>";
 			print "<td>".$refcomp."</td>";
 			if ($obj->total_ttc < 0) { print "<td align=\"right\">".price($total_ttc)."</td><td>&nbsp;</td>"; };
diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php
index 0411f05bfa3a03ef9b574bce7e006a5b616c1818..93ecf2e38d6f87caffe444651241afbc530905db 100644
--- a/htdocs/compta/facture/prelevement.php
+++ b/htdocs/compta/facture/prelevement.php
@@ -167,8 +167,8 @@ if ($_GET["facid"] > 0)
 		 *
 		 */
 
-		$sql = "SELECT pfd.rowid, pfd.traite,".$db->pdate("pfd.date_demande")." as date_demande";
-		$sql .= " ,".$db->pdate("pfd.date_traite")." as date_traite";
+		$sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
+		$sql .= " , pfd.date_traite as date_traite";
 		$sql .= " , pfd.amount";
 		$sql .= " , u.rowid as user_id, u.name, u.firstname, u.login";
 		$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
@@ -222,7 +222,7 @@ if ($_GET["facid"] > 0)
 				$var=!$var;
 
 				print "<tr $bc[$var]>";
-				print '<td align="left">'.dol_print_date($obj->date_demande,'day')."</td>\n";
+				print '<td align="left">'.dol_print_date($db->jdate($obj->date_demande),'day')."</td>\n";
 				print '<td align="center">En attente de traitement</td>';
 				print '<td align="center">'.price($obj->amount).'</td>';
 				print '<td align="center">-</td>';
@@ -243,8 +243,8 @@ if ($_GET["facid"] > 0)
 			dol_print_error($db);
 		}
 
-		$sql = "SELECT pfd.rowid, pfd.traite,".$db->pdate("pfd.date_demande")." as date_demande";
-		$sql .= " ,".$db->pdate("pfd.date_traite")." as date_traite";
+		$sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande";
+		$sql .= " , pfd.date_traite";
 		$sql .= " , pfd.fk_prelevement_bons, pfd.amount";
 		$sql .= " , u.rowid as user_id, u.name, u.firstname, u.login";
 		$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
@@ -267,9 +267,9 @@ if ($_GET["facid"] > 0)
 
 				print "<tr $bc[$var]>";
 
-				print '<td align="center">'.dol_print_date($obj->date_demande)."</td>\n";
+				print '<td align="center">'.dol_print_date($db->jdate($obj->date_demande))."</td>\n";
 
-				print '<td align="center">'.dol_print_date($obj->date_traite)."</td>\n";
+				print '<td align="center">'.dol_print_date($db->jdate($obj->date_traite))."</td>\n";
 
 				print '<td align="center">'.price($obj->amount).'</td>';
 
diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php
index ae4235bba98bc3df9a7fadebe97ae5c486f4d568..d50d11d9f82f82beb3fc46b2f14ba5bc66b35826 100644
--- a/htdocs/compta/paiement/cheque/fiche.php
+++ b/htdocs/compta/paiement/cheque/fiche.php
@@ -348,7 +348,7 @@ else
 
 	// Liste des cheques
 	$sql = "SELECT b.rowid, b.amount, b.num_chq, b.emetteur,";
-	$sql.= " ".$db->pdate("b.dateo")." as date,".$db->pdate("b.datec")." as datec, b.banque,";
+	$sql.= " b.dateo as date, b.datec as datec, b.banque,";
 	$sql.= " p.rowid as pid";
 	$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
 	$sql.= ", ".MAIN_DB_PREFIX."bank as b";