Date Calculator API: Documentation

Get Started with the Date Calculator API

Calculate the number of business days (working days) between two dates, or find a future business date – with a few lines of code in your language of choice.

Install Official Libraries

To get started, use one of timeanddate.com's official API libraries for your programming language. If your language isn't supported, you can send the requests manually over HTTP. If you would like to request an official library for your language, please contact us.


    $ dotnet add package TimeAndDate.Services
                

Build Query

The API library is now installed. Next, you specify your start date and the amount of business days you want to count in the location of your choice. In this example, we use latitude and longitude to define the location; you can use a country or state instead. More on that in the reference documentation.

To perform the query, you will need your access key and secret key: Get them from the Access Key page on My Account. Don't have a key? Sign up for our free trial and receive an access key to try it out.


    var coordinates = new Coordinates(59.743m, 10.204m);
    var location = new LocationId(coordinates);
    var now = DateTime.Now;
    var days = 14;
    var service = new BusinessDateService('accessKey', 'secretKey');
    service.Filter = BusinessDaysFilterType.Weekend | BusinessDaysFilterType.Holidays;
                

Get Result

The result variable will now contain a BusinessDates object. It contains: the period you queried for, the end date (business date) you are looking for, the amount of individual days, and any holidays in your given period.


    // Count forward from start date
    var result = service.AddDays(now, days, location);
    // Count backwards from start date
    var result = service.SubtractDays(now, days, location);
                

Where to go next?

See our GitHub repository for more information on the C#/.NET Library.


    <repository>
        <id>github</id>
        <name>Time and Date API Packages</name>
        <url>https://maven.pkg.github.com/timeanddate/libtad-jvm</url>
    </repository>
    <dependency>
        <groupId>com.timeanddate</groupId>
        <artifactId>services</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </dependency>
                    

Build Query

The API library is now installed. Next, you specify your start date and the amount of business days you want to count in the location of your choice. In this example, we use latitude and longitude to define the location; you can use a country or state instead. More on that in the reference documentation.

To perform the query, you will need your access key and secret key: Get them from the Access Key page on My Account. Don't have a key? Sign up for our free trial and receive an access key to try it out.


    Coordinates coordinates = new Coordinates(59.743m, 10.204m);
    LocationId location = new LocationId(coordinates);
    TADDateTime date = new TADDateTime(2020, 11, 26);
    BusinessDateService service = new BusinessDateService('accessKey', 'secretKey');
    
    service.Filter = EnumSet.of(BusinessDaysFilterType.Weekend | BusinessDaysFilterType.Holidays);
                    

Get Result

The result variable will now contain a BusinessDates object. It contains: the period you queried for, the end date (business date) you are looking for, the amount of individual days, and any holidays in your given period.


    // Count forward from start date
    BusinessDates result = service.AddDays(now, days, location);
    // Count backwards from start date
    BusinessDates result = service.SubtractDays(now, days, location);
                    

Where to go next?

See our GitHub repository for more information on the Java/JVM Library.


    # Carthage
    github "TimeAndDate/TadApi"
    # CocoaPods
    pod 'libtad-swift', '~> 1.0'
                    

Build Query

The API library is now installed. Next, you specify your start date and the amount of business days you want to count in the location of your choice. In this example, we use latitude and longitude to define the location; you can use a country or state instead. More on that in the reference documentation.

To perform the query, you will need your access key and secret key: Get them from the Access Key page on My Account. Don't have a key? Sign up for our free trial and receive an access key to try it out.


    let service = BusinessDateService(accessKey: "YOUR_ACCESS_KEY", secretKey:"YOUR_SECRET_KEY")
    let request = BusinessDateRequest()
    request.filter = [BusinessDaysFilterType.weekend, BusinessDaysFilterType.holidays]
    request.placeId = "+59.743-10.204m"
    request.startDate = Date()
    request.days = 14
    
    // Count forward from start date
    request.op = BusinessDaysOperatorType.add
    // Count backward from start date
    request.op = BusinessDaysOperatorType.subtract
                    

Get Result

The result variable will now contain a BusinessDates object. It contains: the period you queried for, the end date (business date) you are looking for, the amount of individual days, and any holidays in your given period.


    service.calculateBusinessDate(request:request) { (result, error) in 
        print(result)
    }
                    

Where to go next?

See our GitHub repository for more information on the Swift Library.


    $ pip3 install libtad
                

Build Query

The API library is now installed. Next, you specify your start date and the amount of business days you want to count in the location of your choice. In this example, we use latitude and longitude to define the location; you can use a country or state instead. More on that in the reference documentation.

To perform the query, you will need your access key and secret key: Get them from the Access Key page on My Account. Don't have a key? Sign up for our free trial and receive an access key to try it out.


    from libtad import BusinessDateService
    from libtad.datatypes.places import Coordinates, LocationId
    from libtad.datatypes.time import TADDateTime
    from libtad.datatypes.business import BusinessDaysFilterType, BusinessDaysOperatorType
    
    coordinates = Coordinates(59.743, 10.204)
    place = LocationId(coordinates)
    date = TADDateTime(2020, 11, 26)
    days = 14
    service = BusinessDateService("accessKey", "secretKey")
    service.filter = [BusinessDaysFilterType.Weekend, BusinessDaysFilterType.Holidays]
    
    # Count forward from start date
    service.operator = BusinessDaysOperatorType.Add
    # Count backwards from start date
    service.operator = BusinessDaysOperatorType.Subtract
                

Get Result

The result variable will now contain a BusinessDates object. It contains: the period you queried for, the end date (business date) you are looking for, the amount of individual days, and any holidays in your given period.


    result = service.get_business_date_for_place(place, date, days)
                

Where to go next?

See our GitHub repository for more information on the Python Library.


    gem 'libtad'
                

Build Query

The API library is now installed. Next, you specify your start date and the amount of business days you want to count in the location of your choice. In this example, we use latitude and longitude to define the location; you can use a country or state instead. More on that in the reference documentation.

To perform the query, you will need your access key and secret key: Get them from the Access Key page on My Account. Don't have a key? Sign up for our free trial and receive an access key to try it out.


    location = "usa/new-york"
    now = TADDateTime.now
    days = 14
    filter = [:weekend, :holidays]
    client = LibTAD::Client.new(access_key: 'access_key', secret_key: 'secret_key')
                

Get Result

The result variable will now contain a BusinessDates object. It contains: the period you queried for, the end date (business date) you are looking for, the amount of individual days, and any holidays in your given period.


    # Count forward from start date
    result = client.add_days(place_id: place, start_date: now, filter: filter, days: days)
    # Count backwards from start date
    result = client.subtract_days(place_id: place, start_date: now, filter: filter, days: days)
                

Where to go next?

See our GitHub repository for more information on the Ruby Library.

Build Query

You will need cURL installed in order to execute the following commands. The following samples also require you to have enabled "Insecure Methods" on your access key.


$ ACCESSKEY="<Your Access Key>"
$ SECRETKEY="<Your Secret Key>"
$ curl -G \
    --data-urlencode "version=3" \
    --data-urlencode "prettyprint=1" \
    --data-urlencode "accesskey=$ACCESSKEY" \
    --data-urlencode "secretkey=$SECRETKEY" \
    --data-urlencode "placeid=norway/oslo" \
    --data-urlencode "startdt=2020-05-10" \
    --data-urlencode "days=14" \
    --data-urlencode "op=add" \
    --data-urlencode "filter=weekend,holidays" \
    https://api.xmltime.com/businessdate
                    

Get Result

Execute cURL with the parameters set previously and receive the resulting calculation as a JSON object.


    {
      "version": 3,
      "billing": {
        "credits": 1
      },
      "geo": {
        "latitude": 59.913055,
        "longitude": 10.740001,
        "name": "Oslo",
        "country": {
          "id": "no",
          "name": "Norway"
        },
        "state": ""
      },
      "periods": [{
        "includeddays": 14,
        "calendardays": 19,
        "skippeddays": 5,
        "startdate": {
          "iso": "2020-05-10",
          "datetime": {
            "year": 2020,
            "month": 5,
            "day": 10
          }
        },
        "enddate": {
          "iso": "2020-05-29",
          "datetime": {
            "year": 2020,
            "month": 5,
            "day": 29
          }
        },
        "weekdays": {
          "type": "excluded",
          "count": 4,
          "mon": 0,
          "tue": 0,
          "wed": 0,
          "thu": 0,
          "fri": 0,
          "sat": 2,
          "sun": 2
        },
        "holidays": {
          "type": "excluded",
          "count": 1,
          "list": [{
            "id": 1501,
            "urlid": "norway/ascension-day",
            "uid": "0005dd00000007e4",
            "url": "https://www.timeanddate.com/holidays/norway/ascension-day",
            "name": [{
              "lang": "en",
              "text": "Ascension Day"
            }],
            "date": {
              "iso": "2020-05-21",
              "datetime": {
                "year": 2020,
                "month": 5,
                "day": 21
              }
            }
          }]
        }
      }]
    }
                    

Install Official Libraries

To get started, use one of timeanddate.com's official API libraries for your programming language. If your language isn't supported, you can send the requests manually over HTTP. If you would like to request an official library for your language, please contact us.


    $ dotnet add package TimeAndDate.Services
                    

Build Query

Now that we have the API library installed, we can specify what our start date and end date is in order to determine how many business/working days is between those two dates, for any location. In this example we use latitude and longitude, but you can also use country/state. See our documentation for the complete reference.

To perform the query, you will need your access key and secret key: Get them from the Access Key page on My Account. Don't have a key? Sign up for our free trial and receive an access key to try it out.


    var coordinates = new Coordinates(59.743m, 10.204m);
    var location = new LocationId(coordinates);
    var now = DateTime.Now;
    var then = DateTime.Now.AddDays(14);
    var service = new BusinessDurationService('accessKey', 'secretKey');
    service.Filter = BusinessDaysFilterType.Weekend | BusinessDaysFilterType.Holidays;
                    

Get Result

The result variable will now contain a BusinessDuration object, with the period you queried for, how many individual business/working days as well as the number of calendar days in that period, and which holidays.


    var result = service.GetDuration(now, then, location);
                    

Where to go next?

See our GitHub repository for more information on the C#/.NET Library.


    <repository>
        <id>github</id>
        <name>Time and Date API Packages</name>
        <url>https://maven.pkg.github.com/timeanddate/libtad-jvm</url>
    </repository>
    <dependency>
        <groupId>com.timeanddate</groupId>
        <artifactId>services</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </dependency>
                    

Build Query

Now that we have the API library installed, we can specify what our start date and end date is in order to determine how many business/working days is between those two dates, for any location. In this example we use latitude and longitude, but you can also use country/state. See our documentation for the complete reference.

To perform the query, you will need your access key and secret key: Get them from the Access Key page on My Account. Don't have a key? Sign up for our free trial and receive an access key to try it out.


    Coordinates coordinates = new Coordinates(59.743m, 10.204m);
    LocationId location = new LocationId(coordinates);
    TADDateTime startDate = new TADDateTime(2020, 11, 26);
    TADDateTime endDate = new TADDateTime(2020, 12, 26);
    BusinessDurationService service = new BusinessDurationService('accessKey', 'secretKey');
    
    service.Filter = EnumSet.of(BusinessDaysFilterType.Weekend | BusinessDaysFilterType.Holidays);
                    

Get Result

The result variable will now contain a BusinessDuration object, with the period you queried for, how many individual business/working days as well as the number of calendar days in that period, and which holidays.


    BusinessDuration result = service.getDuration(startDate, endDate, location);
                    

Where to go next?

See our GitHub repository for more information on the Java/JVM Library.


    # Carthage
    github "TimeAndDate/TadApi"
    # CocoaPods
    pod 'libtad-swift', '~> 1.0'
                    

Build Query

Now that we have the API library installed, we can specify what our start date and end date is in order to determine how many business/working days is between those two dates, for any location. In this example we use latitude and longitude, but you can also use country/state. See our documentation for the complete reference.

To perform the query, you will need your access key and secret key: Get them from the Access Key page on My Account. Don't have a key? Sign up for our free trial and receive an access key to try it out.


    var businessDurationService = BusinessDurationService(accessKey: "YOUR_ACCESS_KEY", secretKey:"YOUR_SECRET_KEY")
    businessDurationRequest = BusinessDurationRequest()
    businessDurationRequest.placeId = "norway/Oslo"
    businessDurationRequest.country = "no"
                    

Get Result

The result variable will now contain a BusinessDuration object, with the period you queried for, how many individual business/working days as well as the number of calendar days in that period, and which holidays.


    businessDurationService.getBusinessDurationInfo(request:businessDurationRequest) { 
        (result, error) in 
    }
                    

Where to go next?

See our GitHub repository for more information on the Swift Library.


    $ pip3 install libtad
                    

Build Query

Now that we have the API library installed, we can specify what our start date and end date is in order to determine how many business/working days is between those two dates, for any location. In this example we use latitude and longitude, but you can also use country/state. See our documentation for the complete reference.

To perform the query, you will need your access key and secret key: Get them from the Access Key page on My Account. Don't have a key? Sign up for our free trial and receive an access key to try it out.


    from libtad import BusinessDurationService
    from libtad.datatypes.places import Coordinates, LocationId
    from libtad.datatypes.time import TADDateTime
    from libtad.datatypes.business import BusinessDaysFilterType
    
    coordinates = Coordinates(59.743, 10.204)
    place = LocationId(coordinates)
    start_date = TADDateTime(2020, 11, 26)
    end_date = TADDateTime(2020, 12, 26)
    service = BusinessDurationService("accessKey", "secretKey")
    
    service.filter = [BusinessDaysFilterType.Weekend, BusinessDaysFilterType.Holidays]
                    

Get Result

The result variable will now contain a BusinessDuration object, with the period you queried for, how many individual business/working days as well as the number of calendar days in that period, and which holidays.


    result = service.get_business_duration_for_place(place, start_date, end_date)
                    

Where to go next?

See our GitHub repository for more information on the Python Library.


    gem 'libtad'
                

Build Query

Now that we have the API library installed, we can specify what our start date and end date is in order to determine how many business/working days is between those two dates, for any location. In this example we use latitude and longitude, but you can also use country/state. See our documentation for the complete reference.

To perform the query, you will need your access key and secret key: Get them from the Access Key page on My Account. Don't have a key? Sign up for our free trial and receive an access key to try it out.


    location = "usa/new-york"
    start = TADDateTime.new(year: 2021, month: 2, day: 12)
    end = TADDateTime.new(year: 2021, month: 2, day: 23)
    filter = [:weekend, :holidays]
    client = LibTAD::Client.new(access_key: 'access_key', secret_key: 'secret_key')
                

Get Result

The result variable will now contain a BusinessDuration object, with the period you queried for, how many individual business/working days as well as the number of calendar days in that period, and which holidays.


    result = client.get_duration(start_date: start_date, end_date: end_date, place_id: place, filter: filter)
                

Where to go next?

See our GitHub repository for more information on the Ruby Library.

Build Query

You will need cURL installed in order to execute the following commands. The following samples also require you to have enabled "Insecure Methods" on your access key.


$ ACCESSKEY="<Your Access Key>"
$ SECRETKEY="<Your Secret Key>"
$ curl -G \
    --data-urlencode "version=3" \
    --data-urlencode "prettyprint=1" \
    --data-urlencode "accesskey=$ACCESSKEY" \
    --data-urlencode "secretkey=$SECRETKEY" \
    --data-urlencode "placeid=norway/oslo" \
    --data-urlencode "startdt=2020-05-10" \
    --data-urlencode "enddt=2020-05-30" \
    --data-urlencode "filter=weekend,holidays" \
    https://api.xmltime.com/businessduration
                    

Get Result

Execute cURL with the parameters set previously and receive the resulting calculation as a JSON object.


    {
      "version": 3,
      "billing": {
        "credits": 1
      },
      "geo": {
        "latitude": 59.913055,
        "longitude": 10.740001,
        "name": "Oslo",
        "country": {
          "id": "no",
          "name": "Norway"
        },
        "state": ""
      },
      "period": {
        "includeddays": 14,
        "calendardays": 20,
        "skippeddays": 6,
        "startdate": {
          "iso": "2020-05-10",
          "datetime": {
            "year": 2020,
            "month": 5,
            "day": 10
          }
        },
        "enddate": {
          "iso": "2020-05-30",
          "datetime": {
            "year": 2020,
            "month": 5,
            "day": 30
          }
        },
        "weekdays": {
          "type": "excluded",
          "count": 5,
          "mon": 0,
          "tue": 0,
          "wed": 0,
          "thu": 0,
          "fri": 0,
          "sat": 2,
          "sun": 3
        },
        "holidays": {
          "type": "excluded",
          "count": 1,
          "list": [
            {
              "id": 1501,
              "urlid": "norway/ascension-day",
              "uid": "0005dd00000007e4",
              "url": "https://www.timeanddate.com/holidays/norway/ascension-day",
              "name": [
                {
                  "lang": "en",
                  "text": "Ascension Day"
                }
              ],
              "date": {
                "iso": "2020-05-21",
                "datetime": {
                  "year": 2020,
                  "month": 5,
                  "day": 21
                }
              }
            }
          ]
        }
      }
    }