Working with data ranges

Dataddo is able to define a dynamic date range relative to the current date.

When is the dynamic range needed?

Imagine a situation where date-related params must be defined as part of the API call.

https://api.service.com/endpoint?startDate=2019-07-01&endDate=2019-07-31

If such a call is automated, the extracted dataset will always be the same, which is presumably not ideal. Both startDate and endDate params should be dynamically generated. This can be done using dynamic date range expressions such as follows.

How does it work?

https://api.service.com/endpoint?startDate={{1m1}}&endDate={{1m1}}

The expression is enclosed in double curly brackets consists of three parts:

  1. Integer at the start of expression 1m1. This represents the number of units (days, weeks, or months) to go back from the current date and defines the start of the range. 0 represents the current value.
  2. Unit definition. d = day, m = month, w = week

Examples

Expression examples

Expression Meaning
{{0d0}} Today
{{1d1}} Yesterday
{{1d0}} Yeasterday and today
{{0m0}} This month
{{1m1}} Last month
{{90d1}} Ninety days ago till yesterday
{{1w1}} Last week
{{0w0}} This week starting from monday
{{0y0}} This year
{{1y1}} Last year

API call with 'yesterday' date range

https://api.service.com/endpoint?startDate={{1d1}}&endDate={{1d1}}

API call with 'this month' date range

https://api.service.com/endpoint?startDate={{0m0}}&endDate={{0m0}}

Date string formatting

The date string is by default outputed as YYYY-MM-DD string (e.g. 2019-12-31). Unfortunately, not all APIs follow ISO 8601 standards. In such cases, it is possible to use a date string formating.

Custom formatting examples examples

Expression Output
{{0d0|Ymd}} 20201231
{{0d0|Y-m-d\TH:i:s}} 2020-12-31T00:00:00