diff --git a/entity/Salesproject_entity/recordcontainers/db/recordfieldmappings/inactivetime.value/expression.js b/entity/Salesproject_entity/recordcontainers/db/recordfieldmappings/inactivetime.value/expression.js
index b590c9b4aae70ba5ea597df6f85a9eaafec27c26..c63e4f2ad0b58e228c1addd0b79f9cf866f5e0fb 100644
--- a/entity/Salesproject_entity/recordcontainers/db/recordfieldmappings/inactivetime.value/expression.js
+++ b/entity/Salesproject_entity/recordcontainers/db/recordfieldmappings/inactivetime.value/expression.js
@@ -5,6 +5,7 @@ import("ActivityTask_lib");
 
 var maskingUtils = new SqlMaskingUtils();
 var dateDiff = maskingUtils.dayDateDifference(
+    "current_date",
     SqlUtils.nullableWithDefault(
         ActivityUtils.getLastActivityDateSql("SALESPROJECT.SALESPROJECTID"),
         "SALESPROJECT.DATE_NEW"
diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js
index 0e72ac6f2168627c03804488ae87fcd83be4552b..ca7e8e08ddb18909990414ecffe4d951531bb3ef 100644
--- a/process/Sql_lib/process.js
+++ b/process/Sql_lib/process.js
@@ -3337,10 +3337,11 @@ SqlMaskingUtils.prototype.modulo = function(pField1, pField2)
 
 /**
  * Returns an sql expression resolving into the diffrence between 2 dates in days
- * Notet that pDate2Field is optional it will default to the current date
+ * The expression is a s follows: first_date - second_date
+ * So if the first date is smaller than the second date you will get a negative value returned
  * 
  * @param {string|SqlBuilder} pDateField1 the first date
- * @param {string|SqlBuilder} pDateField2 the optional second date, defaults to the current date
+ * @param {string|SqlBuilder} pDateField2 the second date
  * 
  * @returns the diffrence between the two dates in days
  */
@@ -3349,13 +3350,13 @@ SqlMaskingUtils.prototype.dayDateDifference = function(pDateField1, pDateField2)
     var maskingUtils = new SqlMaskingUtils();
     
     var date1 = maskingUtils.cast("(" + pDateField1.toString() + ")", SQLTYPES.DATE);
-    var date2 = pDateField2 ? maskingUtils.cast("(" + pDateField2.toString() + ")", SQLTYPES.DATE) : "current_date";
+    var date2 = maskingUtils.cast("(" + pDateField2.toString() + ")", SQLTYPES.DATE);
     
     switch(this.dbType)
     {
         case db.DBTYPE_DERBY10:
             // JDBC escape systax is required for timestampdiff
-            return "{fn timestampdiff(SQL_TSI_DAY, " + date1 + ", " + date2 + ")}";
+            return "{fn timestampdiff(SQL_TSI_DAY, " + date2 + ", " + date1 + ")}";
         case db.DBTYPE_POSTGRESQL8:
         case db.DBTYPE_SQLSERVER2000:
             return "datediff(day, " + date1 + ", " + date2 + ")";