diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 3bb5532accfbd6b9c2beecf4463a88d10f62ef77..8b47658bfdf5d958111a426b600a0d0e8b186abe 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1874,18 +1874,20 @@ if ($action == 'create')
 			$mode_reglement_id = (! empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (! empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
 			$remise_percent = (! empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (! empty($soc->remise_percent) ? $soc->remise_percent : 0));
 			$remise_absolue = (! empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (! empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
-			$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : 0;
 
 			// Replicate extrafields
 			$objectsrc->fetch_optionals($originid);
 			$object->array_options = $objectsrc->array_options;
 		}
-	} else {
+		$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? -1 : '';	// Dot not set 0 here (0 for a date is 1970)
+	}
+	else 
+	{
 		$cond_reglement_id = $soc->cond_reglement_id;
 		$mode_reglement_id = $soc->mode_reglement_id;
 		$remise_percent = $soc->remise_percent;
 		$remise_absolue = 0;
-		$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : 0;
+		$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? -1 : '';	// Do not set 0 here (0 for a date is 1970)
 	}
 	$absolute_discount = $soc->getAvailableDiscounts();
 
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index ce369effb4994eed9b6753944f73a41a05d103db..fc1260ea6360ed1cae7b2e0b9b14bf461c0d06a6 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -406,7 +406,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
         // Date payment
         print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>';
         $datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
-        $datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0) : $datepayment);
+        $datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'') : $datepayment);
         $form->select_date($datepayment,'','','',0,"add_paiement",1,1);
         print '</td>';
         print '<td>'.$langs->trans('Comments').'</td></tr>';