Date Functions
Get the number of days, workdays, holidays, and more, by adding date functions to your formulas.
Last updated: June 16, 2022
Date functions in the Advanced and Visual (new) formula editors
The list of the available date functions slightly differs in the Advanced and Visual formula editors. This article gives examples of how date functions work in both formula editors.
What are date functions?
A date function is a formula component that calculates the number of days, workdays, holidays, weeks, months, years, and more. Date functions such as Workdays allow you to display your KPIs more precisely and exclude the days when you're not at work (for example, weekends, holidays).
Available date functions
Here's a list of date functions that we support currently:
- Visual editor: Workdays, Holidays, Days, Weeks, Months, Years.
- Advanced editor: NetWorkDays, Holidays, Days, Weeks, Months, Years, Hour, Day, Month, Year.
Date and time objects
Each of the date functions contains smaller arguments called date and time objects. These objects are indicators that tell Plecto when or what to consider in the calculations. Here's a list of date and time objects you can add in the Visual and Advanced
formula editors:
- Today |
Today()
Today until 23:59:59. - Now |
Now()
The date and time right now. - Widget start date |
Startdate()
The start date and time of the selected time period on the widget. - Widget end date |
Enddate()
The start date and time of the selected time period on the widget. - Fixed date |
Date(yyyy,mm,dd)
Allows you to select a custom date range.
Example: Your widget's time period is set to the current month. Depending on what date and time objects you select for your date function, Plecto can count the number of days, workdays, etc.
- From widget start date to today (start of the widget's time period to today),
- From widget start date to end date (the entire time period selected on the widget),
- Between fixed dates,
and much more.
Date functions vs. time period
Date functions perform a calculation – they don't establish or change the time period on your widgets. Same as the widget's time period doesn't affect the date function – the time period sets a frame within which the date function result is displayed.
Workdays
Returns the number of working days within a selected time period. If you add Start date: Widget start date, End date: Widget end date and set the time period on the widget to current month, the formula will return a value of 21 for April this year (2022), 23 for March, etc. depending on the number of workdays in the month.

Advanced formula editor
In the Advanced formula editor, the date function is called NetWorkDays, and the functionality is the same as in the Visual editor. To get the number of NetWorkDays from the Advanced editor, you can use the following formula:
(
NetWorkDays(StartDate(),EndDate())
)
Build a formula with custom working days
Read more about Workdays and how to set up custom working days.
Holidays
Returns the number of holidays within a time period. Here you have to select a country to help Plecto understand how many holidays it needs to calculate. See the list of the available countries.
For example, to get the number of holidays in Denmark this month, you can create the following component. Set the time period on the widget to the current month.

Advanced formula editor
In the Advanced formula editor, the date function is called Holidays. This function requires you to include a country code, for example, "US"
, to help Plecto understand from which country it needs to calculate the number of holidays. Find the list of the available country codes in this article. You can use the following formula example:
(
Holidays("US",StartDate(),EndDate())
)
Days
Returns the number of days within a time period. The number depends on the start and end dates you select in the formula, as well as the time period on your widget.
For example, if you add Start date: Widget start date, End date: Widget end date and set the time period on the widget to the current month, then Plecto will count the total number of days this month. In June, the number will be 30, in October - 31.

Advanced formula editor
In the Advanced formula editor, the date function is called Days. You can use the following formula example to count the number of days from the widget start date to end date:
(
Days(Startdate(),Enddate())
)
Tip – Use date functions to create MTD target formulas
You can incorporate the Days and Workdays functions in your formulas to create month-to-date targets. Read this article to learn more.
Weeks
Returns the number of weeks within the selected time period. For example, if you select the current month time period on the widget, the formula will return 4 (or 5, depending on the month).

Advanced formula editor
In the Advanced formula editor, the date function is called Weeks. You can use the following formula example to count the number of weeks from the widget start date to end date:
(
Weeks(Startdate(),Enddate())
)
Months
Returns the number of months within the selected time period. For example, if you select the current year on the widget, the formula will return 12.

Advanced formula editor
In the Advanced formula editor, the date function is called Months. You can use the following formula example to count the number of months from the widget start date to end date:
(
Months(Startdate(),Enddate())
)
Years
Returns the number of years within the selected time period. For example, if you select the Current Year time period on the widget, the formula will return 1.

Hour
Supported in the Advanced formula editor
This date function is called Hour, and it returns the date's hour, for example, "11" for 11:23 am. This function will return a numerical value of the current hour, and regardless if the hour now is 11:23 am or 11:55 am, it will output a number value of 11.
The following formula will output a number value of the current hour.
(
Hour(Now())
)
Day
Supported in the Advanced formula editor
This date function is called Day, and it returns the date's day, for example, "10" for the 10th of June. The result depends on both the date object included in the formula and the time period selected on the widget.
If you use a formula like the following, it will output a decimal number of the current day. For example, if it is currently the 10th of June, the widget will display 10.
(
Day(Today())
)
Month
Supported in the Advanced formula editor
This date function is called Month, and it returns the date's month, for example, "8" for August. The result depends on both the date object included in the formula (see the section above) and the time period selected on the widget.
If you use a formula like the following, it will output a decimal number of the current month. For example, if the current month is August, the widget will display 8.
(
Month(Today())
)
Year
Supported in the Advanced formula editor
This date function is called Year, and it returns a year. For example, 2022. To see the year of today, use the following formula:
(
Year(Today())
)
Tip – Change the number format to Text
Change the number formatting to text to make sure the widget displays, for example, 2022. If you choose the decimal number format instead, the widget will display the result with a thousand separator, for example, 2.022 or 2,022, depending on your localization.
Was this article helpful?
Please leave a comment to help us improve.