businessduration – Calculate business days in a specified date range

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
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 email api@timeanddate.com.

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 called “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=187&startdt=2015-04-01&enddt=2015-04-30&version=2&out=xml&prettyprint=1&accesskey={KEY}&expires={TIMESTAMP}&signature={SIGNATURE}

Example JSON response

		
{
    "version": 2,
    "geo": {
        "latitude": 59.913055,
        "longitude": 10.740001,
        "name": "Oslo",
        "country": {
            "id": "no",
            "name": "Norway"
        },  
        "state": ""
    },  
    "period": {
        "includeddays": 18, 
        "calendardays": 29, 
        "skippeddays": 11, 
        "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": 3,
            "list": [{
                "id": 1497,
                "urlid": "norway/maundy-thursday",
                "uid": "0005d900000007df",
                "url": "http://www.timeanddate.com/holidays/norway/maundy-thursday",
                "name": "Maundy Thursday",
                "date": {
                    "iso": "2015-04-02",
                    "datetime": {
                        "year": 2015,
                        "month": 4,
                        "day": 2
                    }   
                }   
            },{ 
                "id": 1498,
                "urlid": "norway/good-friday",
                "uid": "0005da00000007df",
                "url": "http://www.timeanddate.com/holidays/norway/good-friday",
                "name": "Good Friday",
                "date": {
                    "iso": "2015-04-03",
                    "datetime": {
                        "year": 2015,
                        "month": 4,
                        "day": 3
                    }   
                }   
            },{ 
                "id": 1500,
                "urlid": "norway/easter-monday",
                "uid": "0005dc00000007df",
                "url": "http://www.timeanddate.com/holidays/norway/easter-monday",
                "name": "Easter Day",
                "date": {
                    "iso": "2015-04-06",
                    "datetime": {
                        "year": 2015,
                        "month": 4,
                        "day": 6
                    }
                }
            }]
        }
    }
}

Example XML Request. 

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

Example XML response

<?xml version="1.0" encoding="UTF-8"?>
<data version="2">
  <geo>
    <latitude>59.913055</latitude>
    <longitude>10.740001</longitude>
    <name>Oslo</name>
    <country id="no">Norway</country>
    <state></state>
  </geo>
  <period includeddays="18" calendardays="29" skippeddays="11">
    <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="3">
      <list>
        <holiday id="1497" urlid="norway/maundy-thursday" uid="0005d900000007df" url="http://www.timeanddate.com/holidays/norway/maundy-thursday">
          <name>Maundy Thursday</name>
          <date iso="2015-04-02">
            <datetime>
              <year>2015</year>
              <month>4</month>
              <day>2</day>
            </datetime>
          </date>
        </holiday>
        <holiday id="1498" urlid="norway/good-friday" uid="0005da00000007df" url="http://www.timeanddate.com/holidays/norway/good-friday">
          <name>Good Friday</name>
          <date iso="2015-04-03">
            <datetime>
              <year>2015</year>
              <month>4</month>
              <day>3</day>
            </datetime>
          </date>
        </holiday>
        <holiday id="1500" urlid="norway/easter-monday" uid="0005dc00000007df" url="http://www.timeanddate.com/holidays/norway/easter-monday">
          <name>Easter Day</name>
          <date iso="2015-04-06">
            <datetime>
              <year>2015</year>
              <month>4</month>
              <day>6</day>
            </datetime>
          </date>
        </holiday>
      </list>
    </holidays>
  </period>
</data>

prev top | next >
Terms & Conditions Copyright © Time and Date AS
All data supplied by timeanddate.com