Businessduration

The businessduration service can be used to calculate the number of business days between a specified start date and end date.

When you query the businessduration service with a placeid or a country, a start date and an end date the service will return the number of business days in that date range by excluding public holidays and weekends. Furthermore, you can apply additional filters such as individual days and whether or not the calculation should include the filter result or exclude it.

This service can be tested with the Query Builder.

Request Parameters:

NameDescriptionRequired
placeid

Specify the ID of the location you would like to calculate the business duration. The ID is used to find what holidays are applicable for the given place so the calculation can exclude or include those results.

Note: It is also possible to specify coordinates or IATA/ICAO codes for airports, see the documentation for the type Location Id for detailed information.

Type: String / Location Id

Condition: either the placeid or the country parameter has to be specified.

Conditional
country

Specify the country for which you would like to calculate the business date.

Type: String / ISO3166-1-alpha-2 country code

Condition: either the placeid or the country parameter have to be specified.

Conditional
state

Specify the state in the given country you want to calculate the business date.

Type: String / ISO3166-2 country state code

Condition: only if the country parameter has been specified.

Conditional
startdt

Specify the ISO 8601 date for the date you want to calculate from.

Type: String / ISO8601 Date

Yes
enddt

Specify the ISO 8601 date for the date you want to calculate to.

Type: String / ISO8601 Date

Yes
include

Specify whether the result should be calculated by including instead of excluding the days specified by filter.

Type: Boolean

Default value: 0

No
filter

Choose a set of types or days you want to filter on.

Type: String / Array of Business Days Filter Type

Default value: weekendholidays

No
includelastdate

Whether or not the last date (enddt) should be counted in the result.

Type: Boolean

Default value: 0

No
calendar

List all dates in the requested period with a flag indicating if the date was excluded and/or if the date is a holiday.

Type: Boolean

Default value: 0

No
lang

The preferred language for the texts. An error will be raised if the language code cannot be recognized. In case the text for a specific event cannot be retrieved in the requested language it will be returned in English instead. This is also the default language.

In case you have specific needs for a certain language/translation, please contact us.

Type: String / ISO639 Language Code

Default value: en

No
verbosetime

Adds verbose time specification to all ISO 8601 time stamps.

Type: Boolean

Accepted values: 0 or 1

Default value: 1

No

See also the section “General Parameters”.

Response Elements:

NameDescription
geo

Geographical information about the location.

Type: GeoType

period

This will contain the calculated result for the requested period.

Type: PeriodType

Example JSON Request:

https://api.xmltime.com/businessduration?placeid=190&startdt=2015-04-01&enddt=2015-04-30&version=3&out=json&prettyprint=1&accesskey={KEY}&expires={TIMESTAMP}&signature={SIGNATURE}

Example JSON response:


{
  "version": 3,
  "billing": {
    "credits": 1
  },
  "geo": {
    "latitude": -0.220000,
    "longitude": -78.511948,
    "name": "Quito",
    "country": {
      "id": "ec",
      "name": "Ecuador"
    },
    "state": ""
  },
  "period": {
    "includeddays": 20,
    "calendardays": 29,
    "skippeddays": 9,
    "startdate": {
      "iso": "2015-04-01",
      "datetime": {
        "year": 2015,
        "month": 4,
        "day": 1
      }
    },
    "enddate": {
      "iso": "2015-04-30",
      "datetime": {
        "year": 2015,
        "month": 4,
        "day": 30
      }
    },
    "weekdays": {
      "type": "excluded",
      "count": 8,
      "mon": 0,
      "tue": 0,
      "wed": 0,
      "thu": 0,
      "fri": 0,
      "sat": 4,
      "sun": 4
    },
    "holidays": {
      "type": "excluded",
      "count": 1,
      "list": [{
        "id": 984,
        "urlid": "ecuador/good-friday",
        "uid": "0003d800000007df",
        "url": "https://www.timeanddate.com/holidays/ecuador/good-friday",
        "name": [{
          "lang": "en",
          "text": "Good Friday"
        },{
          "lang": "es",
          "text": "Viernes Santo"
        },{
          "lang": "de",
          "text": "Karfreitag"
        }],
        "date": {
          "iso": "2015-04-03",
          "datetime": {
            "year": 2015,
            "month": 4,
            "day": 3
          }
        }
      }]
    }
  }
}

Example XML Request:

https://api.xmltime.com/businessduration?placeid=190&startdt=2015-04-01&enddt=2015-04-30&version=3&out=xml&prettyprint=1&accesskey={KEY}&expires={TIMESTAMP}&signature={SIGNATURE}

Example XML response


<data version="3">
  <billing>
    <credits>1</credits>
  </billing>
  <geo>
    <latitude>-0.220000</latitude>
    <longitude>-78.511948</longitude>
    <name>Quito</name>
    <country id="ec">Ecuador</country>
    <state></state>
  </geo>
  <period includeddays="20" calendardays="29" skippeddays="9">
    <startdate iso="2015-04-01">
      <datetime>
        <year>2015</year>
        <month>4</month>
        <day>1</day>
      </datetime>
    </startdate>
    <enddate iso="2015-04-30">
      <datetime>
        <year>2015</year>
        <month>4</month>
        <day>30</day>
      </datetime>
    </enddate>
    <weekdays type="excluded" count="8">
      <mon>0</mon>
      <tue>0</tue>
      <wed>0</wed>
      <thu>0</thu>
      <fri>0</fri>
      <sat>4</sat>
      <sun>4</sun>
    </weekdays>
    <holidays type="excluded" count="1">
      <list>
        <holiday id="984" urlid="ecuador/good-friday" uid="0003d800000007df" url="https://www.timeanddate.com/holidays/ecuador/good-friday">
          <name>
            <text lang="en">Good Friday</text>
            <text lang="es">Viernes Santo</text>
            <text lang="de">Karfreitag</text>
          </name>
          <date iso="2015-04-03">
            <datetime>
              <year>2015</year>
              <month>4</month>
              <day>3</day>
            </datetime>
          </date>
        </holiday>
      </list>
    </holidays>
  </period>
</data>