<@U04S8PLJWMT> using datetimebased cursor, how can...
# ask-ai
j
@kapa.ai using datetimebased cursor, how can I make the start time start one second later than the stored state? my request is inclusive of the data
k
To make the start time begin one second after the stored state when using a
DatetimeBasedCursor
(to avoid re-fetching the last record if your API's filter is inclusive), you need to ensure that the value used for the next sync's
start_time
is incremented by one second compared to the last emitted record's cursor value. However, the official Airbyte documentation for config-based connectors and
DatetimeBasedCursor
does not provide a built-in configuration option to automatically add an offset (like +1 second) to the stored state before using it as the next
start_time
. The default behavior is to use the last emitted record's cursor value as the starting point for the next sync, which is inclusive and may result in re-fetching the last record if your API's filter is also inclusive (e.g.,
created >= start_time
) [see example](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/incremental-syncs#datetimebasedcursor). If you need to skip the last record (i.e., make the next
start_time
exclusive), you would need to implement this logic in a custom connector (Python-based), where you can programmatically add one second to the stored state before using it in your request parameters. This is demonstrated in some custom connector code, where the
start_time
is incremented to avoid re-fetching the last record, but this is not available as a YAML configuration in config-based connectors [see forum discussion](https://discuss.airbyte.io/t/504). Summary: - There is no YAML config option to add an offset to
start_time
in config-based connectors. - To achieve this, you must implement the logic in a custom (Python) connector by incrementing the stored state before using it as the next
start_time
. If you need further guidance on implementing this in a custom connector, let me know!
j
@kapa.ai is it possible to take a datetime and increment by 1 millisecond using jinja?
k
A message from kapa.ai
Based on the provided knowledge sources, you can increment a datetime by a duration using the Jinja macro
duration
. For example, to add one day:
{{ now_utc() + duration('P1D') }}
. However, the documentation does not explicitly show an example for adding 1 millisecond. The
duration
macro does support ISO8601 durations, and the format for 1 millisecond is
PT0.001S
. So, in theory, you could write:
Copy code
jinja {{ some_datetime + duration('PT0.001S') }}
But the documentation does not provide a direct example of adding 1 millisecond, so while this usage aligns with the documented capabilities of the
duration
macro, it is not explicitly confirmed in the sources. Please test this in your environment to ensure it works as expected. Reference: [Interpolation macros - duration](https://docs.airbyte.com/platform/1.7/connector-development/config-based/understanding-the-yaml-file/reference#macros)