Skip to content

Use business days in Views

This page describes how to use business day date expressions in kdb Insights Enterprise Views, and how to configure the calendars that drive them.

Business days (BD) enable date arithmetic in Views that counts only the days on which your business trades or operates. When a date is offset by a number of business days, weekends, non-trading weekdays, and holidays are skipped, so a component asking for "five days of data" returns five business days rather than five calendar days.

Business day arithmetic is driven by two calendars:

  • A workweek, which names the days of the week that count as business days.
  • A holiday calendar, which lists individual dates to exclude, even when they fall on a workweek day.

Using business day expressions in a View needs no special role. Both calendars are configured from the Configure calendars dialog, which is available on the toolbar of every View to users with the Administrator role. The calendars are system-wide: a single workweek and holiday calendar apply to all Views in the deployment.

How business day arithmetic works

A date counts as a business day only when both of the following are true:

  1. Its day of the week is listed in the workweek.
  2. Its date is absent from the holiday calendar.

When a date is offset by a number of business days, the offset steps forward or backward one calendar day at a time and only counts the days that satisfy both conditions.

For example, with a Monday-to-Friday workweek and the holidays 2026-12-25 (a Friday) and 2026-12-28 (the following Monday), expressions evaluated on Thursday 2026-12-24 resolve as follows:

Expression Resolves to Days skipped
NOW-1BD 2026-12-23 (Wednesday) none
NOW+1BD 2026-12-29 (Tuesday) Fri 25 (holiday), Sat 26 and Sun 27 (not in the workweek), Mon 28 (holiday)
NOW+2BD 2026-12-30 (Wednesday) as above

Calendar changes require a browser reload

Both calendars are read once when the Views interface loads. After you make changes to the calendar you must reload your browser before the new workweek or holiday list is used in date arithmetic. Other users must also reload before they see the change.

Use business days in a View

Business day expressions are entered in a rolling view state, so that a component's date range is recalculated relative to the current moment each time the View is opened or the query is run.

To add a business day date to a View:

  1. Open the data editor for your component, as described in set up a data source for Views.

  2. Click the generate view state icon generate view state icon in the date field you want to make relative, for example startTS or endTS.

  3. Click New to add a new view state.

  4. Set Type to one of date, datetime, minute, month, second, time, or timestamp. A Rolling checkbox appears above the Default field.

  5. Select Rolling.

  6. In the Default field, enter a business day expression using the syntax in the next section, for example NOW-5BD.

  7. Click Apply to add the data to the component.

Business day syntax

Business day expressions extend the NOW rolling syntax with a BD unit:

Expression Description
NOW+xBD Adds x business days to NOW.
NOW-xBD Subtracts x business days from NOW.
NOW+xBD@hh:mm:ss.sss Adds x business days to NOW and sets the time.
NOW-xBD@hh:mm:ss.sss Subtracts x business days from NOW and sets the time.

The following examples illustrate typical use:

Example Result
NOW+2BD Adds two business days to NOW.
NOW-7BD@9:00 Subtracts seven business days from NOW and sets the time to 09:00. Useful for a start-of-day query window.
NOW+1BD When NOW is December 31 and January 1 isn't a business day, the result is January 2.

Syntax rules

  • Don't use spaces anywhere in a rolling expression.
  • If Rolling is selected but no expression is entered, NOW is used.
  • The @hh:mm:ss.sss time component only applies to the datetime and timestamp types.

Business days compared to weekdays

You might want to use the weekday expression WD in the same way as BD. However, WD treats Monday to Friday as the weekdays and doesn't honor the workweek or the holiday calendar.

Configure calendars

Update calendars from the web interface

Configure calendars is only available to users with the Administrator preconfigured role. For all other roles the option is hidden from the View toolbar, and the calendars are read-only.

Because the calendars are system-wide, a change made by any Administrator affects business day arithmetic in every View for every user.

To set the workweek and holidays:

  1. Open any View.

  2. Click Configure calendars on the toolbar at the top right of the workspace. The Configure calendars dialog opens, showing the current workweek and holiday list.

    Configure calendars dialog, showing the workweek checkboxes and the Holidays CSV field.

  3. Set the Workweek and Holidays values as described in the following sections.

  4. Click Save to apply your changes, or Cancel to close the dialog without saving.

  5. Reload your browser so that the updated calendars are used.

Workweek

Select the checkbox for each day that counts as a business day. Any day you clear is treated as a non-business day and is skipped by business day arithmetic.

Setting Description
Sunday to Saturday Select each day of the week that is a business day. The default is a Monday-to-Friday workweek, with Saturday and Sunday cleared. Select all seven days to treat every day as a business day.

The workweek isn't restricted to Monday-to-Friday. For example, select Sunday to Thursday for a Sunday-to-Thursday trading week, or Monday to Saturday for a six-day week.

At least one day must be selected

If no day is selected, business day arithmetic doesn't run: date expressions are left unchanged rather than adjusted, and no error is displayed in the interface. See Troubleshooting.

Holidays

Enter the dates to exclude from business day counting in the Holidays CSV field, using the yyyy-mm-dd format. A holiday is excluded even when its day of the week is part of the workweek.

Setting Description
Holidays CSV One holiday per date, in yyyy-mm-dd format, for example 2026-12-25. Separate dates with a comma or a new line. Leave the field empty when there are no holidays.

Observe the following rules when entering holidays:

  • Use a zero-padded four-digit year, two-digit month, and two-digit day: 2026-01-05, not 2026-1-5.
  • Don't use quotes, date ranges, time values, time zones, or a header row.
  • A multi-day closure needs one date per line. For example, a four-day closure from Monday 2026-09-21 to Thursday 2026-09-24 is entered as four separate dates.
  • A repeated date isn't accepted.
  • Order doesn't matter; the list doesn't need to be sorted.

An empty holiday list is valid

Leaving Holidays CSV empty isn't an error. Business day arithmetic continues using the workweek alone, with no dates excluded.

Update calendars with the CLI

As an alternative to the Configure calendars dialog, administrators can update the calendar files with the kxi pm file commands in the command line interface (CLI).

You can use these commands in scripts, keep calendar files in source control, and deploy the same calendars to multiple deployments. For the complete command reference, see Manage files on the Package Manager service.

Prerequisites

Before you update the calendar files:

  • Install the CLI and authenticate with your deployment.
  • Ensure that you have administrator access. The same access requirement applies when you use the Configure calendars dialog.

A new kdb Insights Enterprise installation doesn't include the calendar files, so you must create them the first time. When updating existing calendars, download and edit the current files to keep the existing entries.

  1. Check whether the calendar files already exist. Add -o json for output that is easier to script against.

    kxi pm file list
    
  2. If workweek.csv and holidayCalendar.csv appear in the list, download them so you can edit them. Otherwise, skip this step.

    kxi pm file get workweek.csv
    kxi pm file get holidayCalendar.csv
    
  3. Create or edit the local files, following the format and parsing rules in the calendar file reference. For example, a workweek.csv for a Monday-to-Friday week:

    2,3,4,5,6
    

    And a holidayCalendar.csv for the 2026 year-end closure:

    2026-12-25
    2026-12-28
    

    Create workweek.csv first. The holiday list is only read once the workweek contains at least one business day.

  4. Upload the files to the calendar path. If a file already exists at the path, it's replaced.

    kxi pm file put workweek.csv
    kxi pm file put holidayCalendar.csv
    

    Always replace the whole file

    kxi pm file put replaces the file at the remote path; it doesn't merge entries. When updating, start from the downloaded file so you don't drop existing holidays. An empty or invalid workweek.csv disables business day arithmetic. See Troubleshooting.

  5. Confirm the upload by listing the files again.

    kxi pm file list
    
  6. Reload your browser. As with changes made in the dialog, the calendars are read once when the Views interface loads, so each user must reload before the change takes effect.

To delete a calendar file, run kxi pm file rm with the exact remote path.

kxi pm file rm holidayCalendar.csv

Calendar file reference

The calendars are stored as two CSV files that the Views interface fetches at load time, from the calendar directory on the web server:

http(s)://<hostname>/modules/<version>/calendar

Defines which days of the week are business days, as a comma-separated list of integers from 1 to 7. Each number names one business day; every day you omit is a non-business day.

Value Day
1 Sunday
2 Monday
3 Tuesday
4 Wednesday
5 Thursday
6 Friday
7 Saturday

A standard Monday-to-Friday week, which is the default:

2,3,4,5,6

A Sunday-to-Thursday week, as used in some Middle East markets:

1,2,3,4,5

A six-day week, Monday to Saturday:

2,3,4,5,6,7

Every day a business day:

1,2,3,4,5,6,7

Note the following about how the file is parsed:

  • Order doesn't matter. 6,2,4,3,5 is the same week as 2,3,4,5,6.
  • Duplicates are ignored, so 2,2,3 is the same as 2,3.
  • Values outside 1 to 7, blank entries, and non-numeric entries are silently skipped. 2,3,x,4,,5,6 still parses as Monday-to-Friday.
  • Only the first seven valid entries are used. Anything after the seventh valid number is ignored.
  • Newlines are treated exactly like commas, so one value per line is also valid and can be mixed with commas. A trailing newline is harmless.

    2
    3
    4
    5
    6
    
  • Double quotes are stripped before parsing, so "2","3","4","5","6" works, but plain unquoted numbers are the preferred form.

An empty workweek disables business day arithmetic

If the file doesn't exist, can't be read, or contains no valid value in the range 1 to 7, business days aren't calculated. See Troubleshooting.

Contains the list of exclusionary dates, such as business holidays, as a comma-separated list in the ISO format yyyy-mm-dd. Each listed date is excluded from business day counting, even if its day of the week appears in workweek.csv.

2026-09-22,2026-09-24,2026-09-29

A longer list, one date per line, is equally valid:

2026-01-01
2026-03-17
2026-04-03
2026-04-06
2026-12-25
2026-12-28

Note the following about how the file is parsed:

  • Use a zero-padded four-digit year, two-digit month, and two-digit day: 2026-01-05, not 2026-1-5. The underlying parser is lenient and also accepts mm-dd-yyyy, optional leading zeros, and dot or forward slash delimiters, but this behavior isn't guaranteed in kdb Insights Enterprise. Always write strict ISO dates, which is the format the Configure calendars dialog produces.
  • Order doesn't matter; the list doesn't need to be sorted. Duplicate dates are ignored.
  • Unparseable entries are silently skipped, so a typo simply means that holiday isn't observed and no error is raised.
  • Newlines are treated like commas, so comma-separated, one-per-line, or a mix of both all work.
  • No time component, time zone, or range is supported. A multi-day holiday must be listed as one entry per day.

Do not quote the dates

Unlike workweek.csv, this file doesn't strip quotes. An entry such as "2026-09-22" fails to parse and the holiday isn't observed.

Load order

The holiday file is only fetched once workweek.csv has yielded at least one business day. If the workweek is empty, the holiday list is never read.

Troubleshooting

Use the following table when business day dates don't resolve as expected.

Symptom Cause Resolution
A BD expression isn't adjusted at all, and the browser console logs No business days defined by <url> The workweek doesn't exist, can't be read, or contains no valid value in the range 1 to 7, so business days aren't calculated. Open Configure calendars, select at least one day in Workweek, click Save, and reload your browser.
A BD expression returns a holiday, or is one day off A holiday entry failed to parse. Unparseable entries are skipped silently, so a typo, a quoted date, or a non-ISO spelling means the holiday isn't observed. Check the entry in Holidays CSV against the holiday rules. Confirm it's unquoted and uses the zero-padded yyyy-mm-dd format.
A holiday is skipped by a BD expression but not by a similar expression elsewhere The other expression uses the WD weekday unit, which excludes weekends only and ignores the holiday calendar. Change the expression to use BD. See business days compared to weekdays.
The date resolves to NOW instead of the offset you entered Rolling is selected but the expression is missing, or it contains a space. Re-enter the expression in the Default field with no spaces, for example NOW-5BD.
The time component of the expression is ignored @hh:mm:ss.sss only applies to the datetime and timestamp types. Change the view state Type to datetime or timestamp.
A saved calendar change has no effect The calendars are read once when the Views interface loads. Reload your browser. Other users must reload before they see the change.
Configure calendars isn't on the View toolbar The option requires the Administrator role. Ask an Administrator to make the change, or have the insights.role.administrator role assigned. See roles for more details.
A multi-day closure is only partly observed Ranges aren't supported, and a repeated date isn't accepted. Enter one date per day of the closure.

Further reading

Back to top