<@U04S8PLJWMT> I’m setting up an App Store Sales R...
# ask-ai
d
@kapa.ai I’m setting up an App Store Sales Report source in the Airbyte Builder The CSV has a
"Begin Date"
column in
MM/DD/YYYY
format (e.g.
09/24/2025
). I transform it into a field
sales_report_date
(
YYYY-MM-DD
) to use for incremental sync. In the Builder, I configured incremental sync like this: • Cursor Field:
sales_report_date
• Cursor Datetime Formats:
%Y-%m-%d
• Start Datetime:
{{ config['report_date'] }}
(from connector config) • End Datetime:
{{ day_delta(-1, format='%Y-%m-%d') }}
(always stop at yesterday) • Cursor Granularity:
P1D
• Step:
P1D
The issue: • The sync keeps resetting instead of advancing. • I want it to always stop at yesterday (never today). • The cursor state (
sales_report_date
) should advance on each run. • First sync should start from the configured
report_date
. Current state looks like this after a run:
Copy code
[
  {
    "type": "STREAM",
    "stream": {
      "stream_descriptor": {
        "name": "sales"
      },
      "stream_state": {
        "sales_report_date": "2025-09-23"
      }
    },
    "sourceStats": {
      "recordCount": 0
    }
  }
]
How should I configure Start Datetime and End Datetime in Builder so the state advances correctly with
sales_report_date
?
k
To ensure your incremental sync in Airbyte Builder advances the state correctly with
sales_report_date
and always stops at yesterday, your configuration is mostly correct, but let's clarify how the Start Datetime and End Datetime should work: ### Key Points from Documentation - Start Datetime: On the first sync, this should be the user-configured value (e.g.,
{{ config['report_date'] }}
). On subsequent syncs, Airbyte will automatically use the last value from the cursor state as the new start date. You do not need to change this logic; Airbyte handles it for you as long as the cursor field and formats are set correctly. - End Datetime: To always stop at yesterday, use a dynamic expression like
{{ day_delta(-1, format='%Y-%m-%d') }}
. This ensures the sync never includes today’s data. - Cursor Field/Format: You have correctly set
sales_report_date
and
%Y-%m-%d
. - Cursor Granularity/Step:
P1D
is correct for daily increments. ### How State Advances - After each sync, Airbyte saves the most recent value of your cursor field (
sales_report_date
) in the state. - On the next sync, it uses this value as the new start date, so records are not re-synced. ### Example from Docs > The most recent encountered date will be saved as the state of the connection - when the next sync is running, it picks up from that cutoff date as the new start date. > ... > The
from-date
is set to the cutoff date of articles synced already and the
to-date
is set to the current date. > [See example](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/incremental-sync#example) ### Troubleshooting: Why Might State Not Advance? - If your sync returns no records (as in your example,
"recordCount": 0
), Airbyte will not advance the state, because it only advances when it reads a record with a newer cursor value. - Make sure your test data includes records for the date range being synced, or the state will not move forward. ### Configuration Recap - Start Datetime:
{{ config['report_date'] }}
- End Datetime:
{{ day_delta(-1, format='%Y-%m-%d') }}
- Cursor Field:
sales_report_date
- Cursor Datetime Formats:
%Y-%m-%d
- Cursor Granularity:
P1D
- Step:
P1D
This setup matches the documented approach for incremental syncs with a date-based cursor and dynamic end date. If the state is not advancing, ensure your data covers the expected date range and that the transformed
sales_report_date
field is present and correctly formatted in your records. For more details, see the [Incremental Sync documentation](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/incremental-sync#example). --- Summary: Your configuration is correct. The state will only advance if records are found in the current sync window. If no records are found, the state remains unchanged. Double-check your data and test with a range that includes records to see the state advance as expected.
d
@kapa.ai I set
report_date = 2025-09-24
. But when I test, the stream creates multiple partitions, like this: Partition 1 start_time: 2025-09-24 end_time: 2025-09-24 Records: 3323 State:
"sales_report_date": "2025-09-24"
Partition 2 start_time: 2025-09-25 end_time: 2025-09-25 Records: 3327 State:
"sales_report_date": "2025-09-25"
Partition 3 start_time: 2025-09-26 end_time: 2025-09-26 Records: 0 State:
"sales_report_date": "2025-09-25"
The problem: • It automatically generates today’s partition (2025-09-26), but I don’t want that. • Sync should always stop at yesterday (latest available report). • Cursor state should advance based on
sales_report_date
. ❓ How should I configure Start Datetime / End Datetime (or partitions) so that only partitions up to yesterday are generated, and not today?
k
A message from kapa.ai
To ensure that your Airbyte incremental sync only generates partitions up to yesterday (never today), you should configure your End Datetime to dynamically resolve to "yesterday"—not today. This is supported and recommended in the Airbyte documentation. ### Correct Configuration - Start Datetime:
{{ config['report_date'] }}
(This is correct; it will use the configured start date and, on subsequent syncs, the state will advance automatically.) - End Datetime:
{{ day_delta(-1, format='%Y-%m-%d') }}
This expression ensures the end date is always set to yesterday, so no partition for today will be created. This approach is explicitly described in the documentation, which states that the end datetime is usually set to the current date and time, but you can use dynamic expressions to control the range. For your use case, using
{{ day_delta(-1, format='%Y-%m-%d') }}
is the correct way to always stop at yesterday and avoid generating a partition for today [see docs](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/incremental-sync#example). ### Why This Works - Partitioning: The sync will create partitions from your start date up to and including the end date. By setting the end date to yesterday, today’s partition will not be created. - State Advancement: The cursor state (
sales_report_date
) will advance to the latest date for which records were found, as long as your data covers those dates [see docs](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/incremental-sync). ### Troubleshooting If you still see a partition for today, double-check that your End Datetime is set exactly to
{{ day_delta(-1, format='%Y-%m-%d') }}
and not to a static or dynamic value that could resolve to today. --- Summary: Set End Datetime to
{{ day_delta(-1, format='%Y-%m-%d') }}
in the Builder. This will ensure only partitions up to yesterday are generated, and the cursor state will advance as expected [see docs](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/incremental-sync#example).
d
@kapa.ai before setting end_time
Copy code
incremental_sync:
      type: DatetimeBasedCursor
      step: P1D
      cursor_field: sales_report_date
      start_datetime:
        type: MinMaxDatetime
        datetime: "{{ config['report_date'] }}"
        datetime_format: "%Y-%m-%d"
      datetime_format: "%Y-%m-%d"
      cursor_granularity: P1D
      cursor_datetime_formats:
        - "%Y-%m-%d"
when i set end_time as {{ day_delta(-1, format='%Y-%m-%d') }} the partition is
Copy code
last partition like this 

sales


Test

Cancel

Partition 2

start_time:

2025-09-24

end_time:

2025-09-25


Records (3323)

Request

Response

Schema

State
[
  {
    "type": "STREAM",
    "stream": {
      "stream_descriptor": {
        "name": "sales"
      },
      "stream_state": {
        "sales_report_date": "2025-09-24"
      }
    },
    "sourceStats": {
      "recordCount": 0
    }
  }
]
Copy code
incremental_sync:
      type: DatetimeBasedCursor
      step: P1D
      cursor_field: sales_report_date
      end_datetime:
        type: MinMaxDatetime
        datetime: "{{ day_delta(-1, format='%Y-%m-%d') }}"
      start_datetime:
        type: MinMaxDatetime
        datetime: "{{ config['report_date'] }}"
        datetime_format: "%Y-%m-%d"
      datetime_format: "%Y-%m-%d"
      cursor_granularity: P1D
      cursor_datetime_formats:
        - "%Y-%m-%d"
k
A message from kapa.ai
Your configuration for
end_datetime
using
{{ day_delta(-1, format='%Y-%m-%d') }}
is correct and aligns with Airbyte's documented approach for limiting partitions to "yesterday" and not including today. This is the recommended way to ensure the sync only generates partitions up to and including yesterday, never today [see docs](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/incremental-syncs#datetimebasedcursor). ### Why does the last partition end at yesterday? With your configuration:
Copy code
yaml incremental_sync:   type: DatetimeBasedCursor   step: P1D   cursor_field: sales_report_date   end_datetime:     type: MinMaxDatetime     datetime: "{{ day_delta(-1, format='%Y-%m-%d') }}"   start_datetime:     type: MinMaxDatetime     datetime: "{{ config['report_date'] }}"     datetime_format: "%Y-%m-%d"   datetime_format: "%Y-%m-%d"   cursor_granularity: P1D   cursor_datetime_formats:     - "%Y-%m-%d"
Airbyte will create daily partitions from your
start_datetime
up to and including the value of
end_datetime
(which resolves to yesterday). This matches the documented behavior: > The sync will create partitions from your start date up to and including the end date. By setting the end date to yesterday, today’s partition will not be created. ### Why does the last partition sometimes show
end_time
as yesterday + 1? Airbyte's partitioning logic for daily steps (
P1D
) creates partitions where each partition covers a single day. For example, if your
start_datetime
is
2025-09-24
and your
end_datetime
is
2025-09-25
, the partition will cover
2025-09-24
(inclusive) to
2025-09-25
(exclusive), which is a standard interval notation. This is consistent with the examples in the documentation, where the end of one partition is the start of the next [see docs](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/incremental-syncs#datetimebasedcursor). ### Cursor state advancement The state will advance to the latest
sales_report_date
for which records were found. If no records are found for a partition, the state will not advance for that partition. ### Summary - Your configuration is correct for stopping at yesterday. - The partitioning logic is expected: each partition covers one day, and the last partition will not include today. - The state will advance as records are found for each partition. If you observe a partition for today, double-check that your
end_datetime
is set exactly as
{{ day_delta(-1, format='%Y-%m-%d') }}
and that your system's timezone is not causing an off-by-one error. For more details, see the [Incremental Syncs documentation](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/incremental-syncs#datetimebasedcursor).
d
@kapa.ai Actually, the
2025-09-25
date data is available, but it should not come in a partition. I expect both
start_time
and
end_time
to be the same (yesterday only). Also, if I remove
P1D
, the extra partitions don’t get created.
k
A message from kapa.ai
Based on the Airbyte documentation, when you set
step: P1D
, the connector will partition the date range into daily windows, where each partition covers one day. The partitioning logic is such that for each partition, the
start_time
is inclusive and the
end_time
is exclusive. This means if your
start_datetime
is
2025-09-24
and your
end_datetime
is
2025-09-25
, you will get a partition for
2025-09-24
only, but the partition will be represented as: -
start_time: 2025-09-24
-
end_time: 2025-09-25
This is expected behavior and is consistent with the examples in the documentation, where the end of one partition is the start of the next, and the last partition's
end_time
is the exclusive upper bound [see docs](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/incremental-syncs#datetimebasedcursor). If you remove
step: P1D
, Airbyte will not partition the date range and will instead create a single partition for the entire range, which is why you see only one partition. To summarize: - The partition with
start_time: 2025-09-24
and
end_time: 2025-09-25
is expected and will only include data for
2025-09-24
. - If you want both
start_time
and
end_time
to be the same (e.g., only
2025-09-24
), you would need to set both
start_datetime
and
end_datetime
to the same value, but this would not be dynamic for daily syncs. - The use of
step: P1D
is what causes the daily partitioning, and this is the intended design according to Airbyte's documentation. If you need only a single day (yesterday) to be synced each time, you could set both
start_datetime
and
end_datetime
to
{{ day_delta(-1, format='%Y-%m-%d') }}
. However, this would not allow the state to advance for incremental syncs, as it would always sync the same day. In conclusion: The partitioning you observe is the documented and expected behavior when using
step: P1D
with a date range. There is no documented way to have both
start_time
and
end_time
be the same for a dynamic, advancing daily incremental sync using the config-based approach in Airbyte. If you need only yesterday's data, set both datetimes to yesterday, but this disables incremental advancement [see docs](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/incremental-syncs#datetimebasedcursor).
d
@kapa.ai This is my sale report request parameter
Copy code
request_parameters:
          filter[version]: "1_0"
          filter[frequency]: DAILY
          filter[reportDate]: "{{ stream_interval.start_time }}"
          filter[reportType]: SALES
          filter[vendorNumber]: "{{ config['vendor_number'] }}"
          filter[reportSubType]: SUMMARY
This incremental sync setup
Copy code
transformations:
      - type: AddFields
        fields:
          - type: AddedFieldDefinition
            path:
              - sales_report_date
            value: "{{ record['Begin Date'][6:10] + '-' + record['Begin Date'][0:2] +\r\n              '-' + record['Begin Date'][3:5] }}"
    incremental_sync:
      type: DatetimeBasedCursor
      step: P1D
      cursor_field: sales_report_date
      end_datetime:
        type: MinMaxDatetime
        datetime: "{{ day_delta(-1, format='%Y-%m-%d') }}"
      start_datetime:
        type: MinMaxDatetime
        datetime: "{{ config['report_date'] }}"
        datetime_format: "%Y-%m-%d"
      datetime_format: "%Y-%m-%d"
      cursor_granularity: P1D
      cursor_datetime_formats:
        - "%Y-%m-%d"
why this not return a report for 2025-09-25? What do I have to set to get 2025-09-25 data that should not return 2025-09-26
k
A message from kapa.ai
Your configuration is almost correct, but the behavior you’re seeing is due to how Airbyte’s
DatetimeBasedCursor
partitions work with the
end_datetime
and
step
settings. ### Why you don’t get a report for
2025-09-25
With your current setup:
Copy code
yaml end_datetime:   type: MinMaxDatetime   datetime: "{{ day_delta(-1, format='%Y-%m-%d') }}"
If you run the sync on
2025-09-26
,
{{ day_delta(-1, format='%Y-%m-%d') }}
evaluates to
2025-09-25
. With
step: P1D
, Airbyte will create partitions from
start_datetime
up to but not including
end_datetime
(the end is exclusive). So, the last partition will be: -
start_time: 2025-09-24
-
end_time: 2025-09-25
This partition will only fetch data for
2025-09-24
, not
2025-09-25
. This is consistent with the documented partitioning logic, where the end of the partition is exclusive ([see docs](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/incremental-syncs#datetimebasedcursor)). ### How to get a report for
2025-09-25
(but not
2025-09-26
) To include
2025-09-25
in your sync, you need the
end_datetime
to be one day after the last date you want to include. So, set:
Copy code
yaml end_datetime:   type: MinMaxDatetime   datetime: "{{ day_delta(0, format='%Y-%m-%d') }}"
If you run the sync on
2025-09-26
, this will set
end_datetime
to
2025-09-26
, so the last partition will be: -
start_time: 2025-09-25
-
end_time: 2025-09-26
This partition will fetch data for
2025-09-25
only, and not for
2025-09-26
. Summary of what to do: - To get data up to and including
2025-09-25
(but not today), set
end_datetime
to today (
{{ day_delta(0, format='%Y-%m-%d') }}
) when running the sync on
2025-09-26
. This matches the documented behavior for
DatetimeBasedCursor
and partitioning with
step: P1D
 ([see docs](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/incremental-syncs#datetimebasedcursor)).