From bedf226a21c71ff1cb92c1ac2e7bc0043a79bc87 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 18 Feb 2022 06:32:45 +0100 Subject: [PATCH] IDEMPIERE-5191 SEARCH FAILURE BY DATE AND HOUR / IDEMPIERE-4962 IDEMPIERE-4724 (#1188) --- .../src/org/compiere/process/InventoryValue.java | 8 ++++++-- .../src/org/compiere/impexp/ImpFormat.java | 10 +++++++--- .../src/org/compiere/db/DB_PostgreSQL.java | 10 +++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/InventoryValue.java b/org.adempiere.base.process/src/org/compiere/process/InventoryValue.java index e23f11157f..da58847e19 100644 --- a/org.adempiere.base.process/src/org/compiere/process/InventoryValue.java +++ b/org.adempiere.base.process/src/org/compiere/process/InventoryValue.java @@ -165,8 +165,12 @@ public class InventoryValue extends SvrProcess // Update Constants // YYYY-MM-DD HH24:MI:SS.mmmm JDBC Timestamp format String myDate = p_DateValue.toString(); - sql = new StringBuilder ("UPDATE T_InventoryValue SET ") - .append("DateValue=TO_DATE('").append(myDate.substring(0,10)) + sql = new StringBuilder ("UPDATE T_InventoryValue SET DateValue="); + if (DB.isPostgreSQL()) + sql.append("TO_TIMESTAMP('"); + else + sql.append("TO_DATE('"); + sql.append(myDate.substring(0,10)) .append(" 23:59:59','YYYY-MM-DD HH24:MI:SS'),") .append("M_PriceList_Version_ID=").append(p_M_PriceList_Version_ID).append(",") .append("C_Currency_ID=").append(p_C_Currency_ID) diff --git a/org.adempiere.base/src/org/compiere/impexp/ImpFormat.java b/org.adempiere.base/src/org/compiere/impexp/ImpFormat.java index aeaa2a1552..876796c880 100644 --- a/org.adempiere.base/src/org/compiere/impexp/ImpFormat.java +++ b/org.adempiere.base/src/org/compiere/impexp/ImpFormat.java @@ -388,10 +388,14 @@ public final class ImpFormat if (!concat) { entry.append(row.getColumnName()); entry.append("="); - if (row.isString()) + if (row.isString()) { entry.append("'"); - else if (row.isDate()) - entry.append("TO_DATE('"); + } else if (row.isDate()) { + if (DB.isPostgreSQL()) + entry.append("TO_TIMESTAMP('"); + else + entry.append("TO_DATE('"); + } } } diff --git a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java index 7e5e86a3a1..aa4035cf59 100755 --- a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java +++ b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java @@ -434,19 +434,19 @@ public class DB_PostgreSQL implements AdempiereDatabase * @param time Date to be converted * @param dayOnly true if time set to 00:00:00 * - * @return TO_DATE('2001-01-30 18:10:20',''YYYY-MM-DD HH24:MI:SS') - * or TO_DATE('2001-01-30',''YYYY-MM-DD') + * @return TO_TIMESTAMP('2001-01-30 18:10:20',''YYYY-MM-DD HH24:MI:SS') + * or TO_TIMESTAMP('2001-01-30',''YYYY-MM-DD') */ public String TO_DATE (Timestamp time, boolean dayOnly) { if (time == null) { if (dayOnly) - return "current_date()"; - return "current_date()"; + return "current_date"; + return "current_timestamp"; } - StringBuilder dateString = new StringBuilder("TO_DATE('"); + StringBuilder dateString = new StringBuilder("TO_TIMESTAMP('"); // YYYY-MM-DD HH24:MI:SS.mmmm JDBC Timestamp format String myDate = time.toString(); if (dayOnly)