{"record":{"id":"cd919c7eda37f83a","repo":"pentaho/pentaho-kettle","slug":"salesforceinput-error-startdatetooolder","errorCode":"SalesforceInput.Error.StartDateTooOlder","errorMessage":"SalesforceInput.Error.StartDateTooOlder","messagePattern":"SalesforceInput\\.Error\\.StartDateTooOlder","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":189,"sourceCode":"  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 ) {\n    this.module = module;\n  }\n\n  public String getURL() {\n    return this.url;\n  }","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforce/SalesforceConnection.java#L171-L207","documentation":"setCalendar() computes the day difference between startDate and endDate and throws this KettleException when the range exceeds 30 days. Salesforce date-based query/retrieval windows are deliberately capped at one month in this wrapper.","triggerScenarios":"Calling setCalendar where endDate - startDate > 30 days, e.g. a quarterly or yearly range requested for RECORDS_FILTER_UPDATED/DELETED queries.","commonSituations":"Users asking for a quarter's worth of updated records in one run; variables like ${YEAR_START}/${YEAR_END} spanning a year; automated jobs that never chunked the range.","solutions":["Split the date range into chunks of 30 days or fewer and run setCalendar/query per chunk.","Narrow the requested window to a single month in the step configuration.","Add scheduler logic that keeps track of the last processed date and only queries the trailing 30-day window each run.","Use getUpdated/getDeleted semantics via a recurring short-window job rather than one large backfill."],"exampleFix":"// before\nconn.setCalendar(filter, cal(2026, 1, 1), cal(2026, 12, 31)); // 364 days\n// after\nGregorianCalendar end = cal(2026, 1, 31); // <= 30 days after start\nconn.setCalendar(filter, cal(2026, 1, 1), end);","handlingStrategy":"validation","validationCode":"long diffDays = (endCal.getTimeInMillis() - startCal.getTimeInMillis()) / 86400000L;\nif (diffDays > 30) {\n  throw new IllegalArgumentException(\"Range exceeds 30 days: \" + diffDays);\n}","typeGuard":"boolean withinLimit = java.time.temporal.ChronoUnit.DAYS.between(start, end) <= 30;","tryCatchPattern":"try {\n  conn.setCalendar(recordsFilter, startCal, endCal);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"StartDateTooOlder\")) {\n    logError(\"Range > 30 days; chunk the window\");\n  }\n}","preventionTips":["Chunk backfills into <=30-day windows.","Persist a high-watermark date and only query trailing windows.","Document the 30-day cap for job designers."],"tags":["salesforce","date-range","value-out-of-range","kettle"],"backgroundTag":"value-out-of-range","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"}