<@U04SE163WC8> Here is the request body I am using...
# ask-ai
d
@kapa.ai Here is the request body I am using for the Airbyte custom connector
Copy code
{
  "report_spec": {
    "metrics": [
      "ESTIMATED_EARNINGS"
    ],
    "date_range": {
      "end_date": {
        "day": 17,
        "year": 2024,
        "month": 7
      },
      "start_date": {
        "day": 17,
        "year": 2024,
        "month": 7
      }
    },
    "dimensions": [
      "DATE",
      "APP",
      "PLATFORM"
    ]
  }
}
How can I dynamically pass the current date's year, month, and day to this request?
k
Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not contain information on how to dynamically pass the current date's year, month, and day to the request body for an Airbyte custom connector. However, you might find it helpful to refer to the [Airbyte Public API documentation](https://airbyte-public-api-docs.s3.us-east-2.amazonaws.com/rapidoc-api-docs.html#post-/v1/sources/update) or the [Airbyte Documentation](https://docs.airbyte.com/) for more information.
d
@kapa.ai Is there a Jinja expression available to retrieve the year from the current date?
k
A message from kapa.ai
New message text here
👍 1
d
@kapa.aiIs there a way to retrieve only the previous day's value using
{{ now_utc().strftime('%d') }}
?
k
A message from kapa.ai
The
now_utc()
function in Jinja returns the current date and time in the UTC timezone. However, it does not directly support operations like subtracting a day. To retrieve the previous day's value, you would typically subtract one day from the current date. Unfortunately, the knowledge sources provided do not contain information on how to perform this operation using Jinja in the context of Airbyte. For more advanced date manipulations, you might need to use additional libraries or tools that can handle date arithmetic, or check if such functionality is available in the environment where your Jinja templates are being rendered. For more information on what's available in Jinja, you can refer to the [Jinja documentation](https://jinja.palletsprojects.com/en/3.0.x/templates/#expressions). For more information on how to use Jinja in Airbyte, you can refer to the [Airbyte documentation](https://docs.airbyte.com/connector-development/config-based/understanding-the-yaml-file/reference#macros).
d
@kapa.ai I see that
{{ day_delta(-1) }}
gives yesterday's date, but is there a way to extract the day value from this date?
k
A message from kapa.ai
Yes, you can extract the day value from the date returned by
{{ day_delta(-1) }}
by using the
strftime()
function. Here is an example:
Copy code
jinja '{{ day_delta(-1).strftime('%d') }}'
This will return the day of the previous date. For example, if today's date is '2021-09-02', the above expression will return '01'. You can find more details about this in the [Airbyte documentation](https://docs.airbyte.com/connector-development/config-based/understanding-the-yaml-file/reference#/macros/Day%20Delta).
d
@kapa.ai change the expression to return "1" instead of "01"
k
A message from kapa.ai
To remove the leading zero from the day value, you can use the
%-d
format code instead of
%d
in the
strftime()
function. Here is an example:
Copy code
jinja '{{ day_delta(-1).strftime('%-d') }}'
This will return the day of the previous date without a leading zero. For example, if yesterday's date was '2021-09-01', the above expression will return '1'. Please note that the
%-d
format code works on Unix-based systems. If you are using a Windows system, you might need to use
'%#d'
instead. You can find more details about this in the [Python strftime() documentation](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes) and the [Airbyte documentation](https://docs.airbyte.com/connector-development/config-based/understanding-the-yaml-file/reference#/macros/Day%20Delta).