I'm using a low code connector, when I define my s...
# ask-ai
m
I'm using a low code connector, when I define my start date I must limit it to the last 45 days. Like this: "{{max(config['start_date'], day_delta(-45, format='%Y-%m-%dT%H:%M:%SZ'))}}" In a different connector I must also format it to date, like: '{{ format_datetime(config["start_date"], "%Y-%m-%d") }}' How to mix both?
k
To combine both requirements—limiting the start date to the last 45 days and formatting it as a date string—you can nest the macros in your low-code connector YAML. Specifically, you should first use the max function to get the later of config['start_date'] and 45 days ago, then pass the result to format_datetime to format it as needed. Here’s how you can do it:
Copy code
yaml {{ format_datetime(max(config['start_date'], day_delta(-45)), '%Y-%m-%d') }}
-
max(config['start_date'], day_delta(-45))
ensures the date is not earlier than 45 days ago. -
format_datetime(..., '%Y-%m-%d')
formats the resulting date as a string in the format your API expects. You do not need to specify the format in day_delta if you are formatting the result afterward. The format_datetime macro expects the input to be an ISO8601 string or datetime object, which is compatible with the output of day_delta and config values, as long as they are in ISO8601 format (which is the default for Airbyte config dates) [see documentation](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/reference#/macros/format_datetime). Example usage:
Copy code
yaml start_datetime:   datetime: "{{ format_datetime(max(config['start_date'], day_delta(-45)), '%Y-%m-%d') }}"   datetime_format: "%Y-%m-%d"
This approach is supported in Airbyte’s low-code CDK and is consistent with the documented macro usage [source](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/reference#/macros/format_datetime).