{"record":{"id":"0961eae70e04aeb0","repo":"pentaho/pentaho-kettle","slug":"salesforceinput-error-wrongdates","errorCode":"SalesforceInput.Error.WrongDates","errorMessage":"SalesforceInput.Error.WrongDates","messagePattern":"SalesforceInput\\.Error\\.WrongDates","errorType":"error_code","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforce/SalesforceConnection.java","lineNumber":183,"sourceCode":"   */\n  @Deprecated\n  public void queryAll( boolean value ) {\n    setQueryAll( value );\n  }\n\n  public void setQueryAll( boolean value ) {\n    this.queryAll = value;\n  }\n\n  public void setCalendar( int recordsFilter, GregorianCalendar startDate, GregorianCalendar endDate ) throws KettleException {\n    this.startDate = startDate;\n    this.endDate = endDate;\n    this.recordsFilter = recordsFilter;\n    if ( this.startDate == null || this.endDate == null ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"SalesforceInput.Error.EmptyStartDateOrEndDate\" ) );\n    }\n    if ( this.startDate.getTime().compareTo( this.endDate.getTime() ) >= 0 ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"SalesforceInput.Error.WrongDates\" ) );\n    }\n    // Calculate difference in days\n    long diffDays =\n      ( this.endDate.getTime().getTime() - this.startDate.getTime().getTime() ) / ( 24 * 60 * 60 * 1000 );\n    if ( diffDays > 30 ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"SalesforceInput.Error.StartDateTooOlder\" ) );\n    }\n  }\n\n  public void setSQL( String sql ) {\n    this.sql = sql;\n  }\n\n  public void setFieldsList( String fieldsList ) {\n    this.fieldsList = fieldsList;\n  }\n\n  public void setModule( String module ) {","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforce/SalesforceConnection.java#L165-L201","documentation":"setCalendar() throws this KettleException when startDate is on or after endDate (compareTo >= 0). The date range supplied is inverted or degenerate, which cannot produce a valid Salesforce query window.","triggerScenarios":"Calling setCalendar with endDate earlier than startDate, or with startDate exactly equal to endDate (zero-length range).","commonSituations":"Start/end date fields swapped in the Salesforce Input dialog; both dates defaulted to the same value from variables; timezone/locale parsing producing identical timestamps for both bounds.","solutions":["Ensure startDate is strictly before endDate in the step configuration.","If you want a single-day window, set endDate to startDate + 1 day instead of the same instant.","Validate the parsed dates in the dialog/parameters before constructing the connection.","Check variable interpolation order so the start value doesn't get assigned to the end field."],"exampleFix":"// before\nGregorianCalendar start = cal(2026, 9, 13), end = cal(2026, 1, 1); // inverted\n// after\nGregorianCalendar start = cal(2026, 1, 1), end = cal(2026, 9, 13); // start < end\nif (!start.getTime().before(end.getTime())) {\n  throw new IllegalArgumentException(\"startDate must be before endDate\");\n}","handlingStrategy":"validation","validationCode":"if (!startCal.getTime().before(endCal.getTime())) {\n  throw new IllegalArgumentException(\"startDate must be strictly before endDate\");\n}","typeGuard":"boolean validRange = startCal != null && endCal != null && startCal.getTime().compareTo(endCal.getTime()) < 0;","tryCatchPattern":"try {\n  conn.setCalendar(recordsFilter, startCal, endCal);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"WrongDates\")) {\n    logError(\"Inverted date range: swap start/end\");\n  }\n}","preventionTips":["Label start/end fields clearly in configs to avoid swaps.","Assert order at parse time, not at query time.","Watch for timezone shifts that equalize the two timestamps."],"tags":["salesforce","date-validation","invalid-argument-value","kettle"],"backgroundTag":"invalid-argument-value","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}