Chapter 4 - Dates and numbers
These eight commands calculate with dates and format dates and numbers: add time or working days to a date, measure the difference between two dates, find a weekday or the day of the year, turn a date or number into display text, and compute the internal rate of return and net present value of a series of cash flows. Chapter 1 explains the command syntax, dynamic parameter values and where results go; this chapter assumes you know it.
The examples use this main data source:
my:myFields
my:StartDate (date)
my:EndDate (date)
my:SubmittedOn (dateTime)
my:DueDate (date)
my:Amount (decimal)
my:DiscountRate (decimal, for example 0.08)
my:CashFlowList (text, for example -1000,300,400,500)
my:Holidays
my:Holiday (date, repeating)
How the date commands read dates. DateAdd, DateDiff, GetDayOfYear and GetWeekDay expect the value as it is stored in a date or dateTime field: YYYY-MM-DD, or YYYY-MM-DDThh:mm:ss (seconds and fractions of a second are optional). They do no time zone conversion: the date and time are used exactly as written, a Z at the end is ignored, and daylight saving changes have no effect on the arithmetic. Use values without a time zone offset. A display value such as 10/9/2026 is not a valid date for these commands.
4.1 DateAdd
Adds (or subtracts) seconds, minutes, hours, days, working days, weeks, months or years to the date in a field and returns the new date. Use it for due dates, reminders and deadlines, including deadlines in business days that skip weekends and holidays.
Syntax
DateAdd /xpath=<XPath> [/dsname=<data source>] [/seconds=<n>] [/minutes=<n>] [/hours=<n>] [/days=<n>] [/weekdays=<n>] [/weeks=<n>] [/months=<n>] [/years=<n>] [/xpathhol=<XPath> [/dsnamehol=<data source>]]
| Parameter | Required | Description |
|---|---|---|
/xpath |
Yes | The date or dateTime field to start from. Only the first match is used. The field itself is not changed. |
/dsname |
No | Data source of that field. Omit for the main data source. |
/seconds |
At least one of these | Seconds to add. A negative number subtracts. |
/minutes |
At least one of these | Minutes to add or subtract. |
/hours |
At least one of these | Hours to add or subtract. |
/days |
At least one of these | Calendar days to add or subtract. |
/weekdays |
At least one of these | Working days to add or subtract: Saturdays, Sundays and the holidays in /xpathhol are skipped. |
/weeks |
At least one of these | Weeks (7 days each) to add or subtract. |
/months |
At least one of these | Months to add or subtract. |
/years |
At least one of these | Years to add or subtract. |
/xpathhol |
No | Only with /weekdays. XPath to a repeating field (or a field in a repeating group) that lists holiday dates to skip. |
/dsnamehol |
No | Data source of the holiday list. Omit for the main data source. |
Result: the new date. If the field holds a date only, the result is YYYY-MM-DD; if it holds a date and time, the result is YYYY-MM-DDThh:mm:ss.
Examples
DateAdd /xpath=/my:myFields/my:StartDate /days=30 /resultxpath=/my:myFields/my:DueDate
DateAdd /xpath=/my:myFields/my:SubmittedOn /hours=-8
DateAdd /xpath=/my:myFields/my:StartDate /weekdays=5 /xpathhol=/my:myFields/my:Holidays/my:Holiday
DateAdd /xpath=/my:myFields/my:StartDate /weekdays=10 /dsnamehol=CompanyHolidays /xpathhol=/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:HolidayDate
The first example writes a due date 30 days after the start date. The third returns the date five working days after the start date, skipping weekends and the dates in the form's holiday table; the fourth does the same with a holiday list from a SharePoint list data source named CompanyHolidays.
Notes
- Several parts can be combined in one command. They are applied in a fixed order, whatever the order you write them in: seconds, minutes, hours, days, weekdays, weeks, months, years.
- Months and years can overflow into the next month. Adding one month to
2026-01-31gives2026-03-03, because February 31 does not exist; adding one year to2024-02-29gives2025-03-01. /weekdaysmoves one day at a time and counts only Monday to Friday days that are not holidays; the start date itself is not counted. From Friday2026-10-09,/weekdays=1gives Monday2026-10-12, and/weekdays=-1gives Thursday2026-10-08.- Holidays are matched by date only. A holiday is recognized only when the starting value has no time of day (a date-only field, or a time of
00:00:00); starting from a dateTime with any other time, holidays are not skipped. - Every node selected by
/xpathholmust contain a valid date. An empty holiday field makes the command fail. If/xpathholselects no node at all (for example an empty holiday table), the command fails with Holidays node could not be selected. - Use whole numbers. A decimal value is not rejected: for most parts the fraction is dropped, and with
/weekdaysa decimal can stop the command from finishing. - The command returns the new value but does not write it anywhere. Use
/resultxpath(Chapter 1) to put it in a field; it can be the same field as/xpath. - Errors: Failed to select the field specified by the XPath., You must specify at least one part to add to the date., If /xpathhol is provided, the weekdays parameter must be used., The field does not contain a valid Date or DateTime value. (also when the field is empty). A value that is not a number fails with The value specified for Hours is not a valid whole number value. (and the same text with Seconds, Minutes, Days, Weeks, Months or Years). For
/weekdaysthe message also says Days.
Related: DateDiff, GetWeekDay, SetValue.
4.2 DateDiff
Calculates the difference between two dates: in whole days, in working days (with optional holidays), as one part (hours, minutes, ...) of the difference, or as a total in days, hours, minutes, seconds or milliseconds.
Syntax
DateDiff /date1=<date> /date2=<date> [/component=<component>] [/xpathhol=<XPath> [/dsnamehol=<data source>]]
| Parameter | Required | Description |
|---|---|---|
/date1 |
Yes | A date value. The result is /date1 minus /date2. Usually given as /date1-xpath= to read a field. |
/date2 |
Yes | The date to subtract from /date1. Usually given as /date2-xpath=. |
/component |
No | What to return. Default weekdays. See the table below. |
/xpathhol |
No | Only with /component=weekdays. XPath to a repeating field (or a field in a repeating group) that lists holiday dates to exclude. |
/dsnamehol |
No | Data source of the holiday list. Omit for the main data source. |
| Component | Short form | Returns |
|---|---|---|
days |
d |
Whole days, rounded down. |
weekdays |
Monday to Friday days, minus holidays. | |
hours |
h |
The hours part of the difference (0 to 23). |
minutes |
m |
The minutes part (0 to 59). |
seconds |
s |
The seconds part (0 to 59). |
milliseconds |
ms |
The milliseconds part (0 to 999). |
totaldays |
td |
The whole difference in days, with decimals. |
totalhours |
th |
The whole difference in hours, with decimals. |
totalminutes |
tm |
The whole difference in minutes. |
totalseconds |
ts |
The whole difference in seconds. |
totalmilliseconds |
tms |
The whole difference in milliseconds. |
Result: a number. It is positive when /date1 is later than /date2.
Examples
DateDiff /date1-xpath=/my:myFields/my:EndDate /date2-xpath=/my:myFields/my:StartDate /component=days
DateDiff /date1-xpath=/my:myFields/my:EndDate /date2-xpath=/my:myFields/my:StartDate /component=weekdays /xpathhol=/my:myFields/my:Holidays/my:Holiday
DateDiff /date1=2026-10-09T17:30:00 /date2=2026-10-08T09:00:00 /component=totalhours
The first returns the number of calendar days between the two dates; the second the number of working days, excluding the holidays in the form. The third returns 32.5; with /component=days, hours and minutes the same two values return 1, 8 and 30.
Notes
- If
/componentis omitted, the command counts weekdays, not calendar days. Always give/componentexplicitly. - Put the later date in
/date1to get a positive number. The Command Builder calls/date1"the start date"; the behavior above is what the engine does. weekdayscounts the days from/date2up to, but not including,/date1, skipping Saturdays, Sundays and holidays. Monday2026-10-05to Friday2026-10-09gives4. With dateTime values only complete 24-hour periods are counted, so use date-only values for weekday counts.- Holidays work as in DateAdd: matched by date only, every holiday field must hold a valid date, and an empty holiday list fails with Holidays node could not be selected. A holiday on a weekend has no effect.
hours,minutes,secondsandmillisecondsreturn one part of the difference, like a clock, not a total. For a negative difference they wrap around (minus one hour gives23). Use thetotal...components for negative differences or totals.daysrounds down, so a difference of minus half a day gives-1.totaldaysgives-0.5.- The component name is not case-sensitive, except with
/xpathhol: then it must be writtenweekdaysin lower case, or the command fails with If /xpathhol is provided, the weekdays component must be used. - A blank or invalid date fails with The first date is invalid. or The second date is invalid. When the dates come from fields that may be empty, run the command only when both have a value. An unknown component fails with The component is invalid.
Related: DateAdd, GetDayOfYear.
4.3 FormatDate
Turns a date into display text, such as October 9, 2026 or 09-Oct-2026, for use in a text field, a file name or an e-mail. It uses .NET standard and custom date and time format strings.
Syntax
FormatDate /date=<date> [/format=<format string>]
| Parameter | Required | Description |
|---|---|---|
/date |
Yes | The date or date and time to format. Usually /date-xpath= pointing to a date field. |
/format |
No | A .NET standard format (one letter, such as d) or a custom format (such as yyyy-MM-dd). Default d, the short date pattern. |
Result: the formatted text. Success is false if the date cannot be formatted.
Examples
FormatDate /date-xpath=/my:myFields/my:StartDate /format=MMMM d, yyyy
FormatDate /date-xpath=/my:myFields/my:SubmittedOn /format=yyyyMMdd-HHmm
FormatDate /date-xpath=/my:myFields/my:StartDate /format=dddd
For a start date of 2026-10-09, the first returns October 9, 2026 and the third Friday (with English month and day names). The second builds a sortable stamp such as 20261009-1730 for a file name.
Notes
- Common custom format tokens:
yyyyyear,MMmonth number,MMM/MMMMshort / full month name,ddday,ddd/ddddshort / full day name,HHhour (24-hour),hhhour (12-hour),mmminutes,ssseconds,ttAM/PM. Tokens are case-sensitive:MMis the month andmmthe minutes. - Standard formats (
d,D,t,g, and so on) and month and day names follow a culture's conventions. FormatDate has no culture parameter, so for a fixed layout use a custom format. - Pass the date as the field stores it (
YYYY-MM-DDorYYYY-MM-DDThh:mm:ss). - The formatting is done by Qdabra Forms, not by the form's own rules. If it fails, the Error field holds the service's message, or Unable to format date.
Related: FormatNumber, DateAdd.
4.4 FormatNumber
Turns a number into display text with a .NET standard or custom numeric format: thousands separators, a fixed number of decimals, currency, percent, leading zeros. Optionally, a culture sets the separators and currency symbol.
Syntax
FormatNumber /value=<number> /format=<format string> [/culture=<culture name>]
| Parameter | Required | Description |
|---|---|---|
/value |
Yes | The number to format. Usually /value-xpath= pointing to a number field. |
/format |
Yes | A .NET standard format (such as N2, C, P1, D6) or a custom format (such as #,##0.00 or 000000). |
/culture |
No | A .NET culture name, such as en-US, de-DE or ja-JP, that controls the decimal and thousands separators and the currency symbol. Omit it to use the default. |
Result: the formatted text. Success is false if the number cannot be formatted.
Examples
FormatNumber /value-xpath=/my:myFields/my:Amount /format=N2
FormatNumber /value-xpath=/my:myFields/my:Amount /format=C /culture=en-US
FormatNumber /value-xpath=/my:myFields/my:Amount /format=N2 /culture=de-DE
FormatNumber /value=0.0825 /format=P2
For an amount of 1234.5, the first returns 1,234.50, the second $1,234.50 and the third 1.234,50. The last returns 8.25 % or 8.25%, depending on the culture.
Notes
- The value must be a plain number with a dot as the decimal separator, the way a number field stores it. Only the leading numeric part is read:
1,234.50is read as1, and12 kgas12. A value that does not start with a number, such as$12, fails with Value '$12' for parameter 'value' is not a valid number. - Common formats:
N2thousands separators and two decimals;F2two decimals without separators;Ccurrency;Ppercent (the value is multiplied by 100);D6or000000pad a whole number with leading zeros;#,##0.00a custom pattern. - The formatting is done by Qdabra Forms. If it fails, the Error field holds the service's message, or Unable to format number.
- The result is text. Write it to a text field, not back into the number field.
Related: FormatDate.
4.5 GetDayOfYear
Returns the day number within the year (1 to 366) for a date, or for today. Useful for sequence numbers, Julian-style date codes and lot numbers.
Syntax
GetDayOfYear [/date=<date>]
| Parameter | Required | Description |
|---|---|---|
/date |
No | The date. If the parameter is left out, today's date (on the user's computer) is used. |
Result: the day number, from 1 for January 1.
Examples
GetDayOfYear
GetDayOfYear /date-xpath=/my:myFields/my:StartDate
The first returns today's day number. For a start date of 2026-10-09, the second returns 282; 2024-12-31 returns 366.
Notes
- Any time of day in the value is ignored.
- A
/datethat is present but empty fails with /date cannot be blank. This includes/date-xpath=pointing to an empty field: the command does not fall back to today. Leave the parameter out for today. - An invalid date fails with Failed to get day of year for date. followed directly by Invalid datetime value: and the value.
Related: GetWeekDay, DateDiff.
4.6 GetWeekDay
Returns the date of a given weekday in the same week as a date. Weeks run from Sunday to Saturday. Use it to find the week-start (Sunday or Monday) or week-ending (Friday or Saturday) date for a timesheet or weekly report.
Syntax
GetWeekDay /day=<day> [/date=<date>]
| Parameter | Required | Description |
|---|---|---|
/day |
Yes | The weekday to return: the full English name (monday) or its first two letters (mo, tu, we, th, fr, sa, su). Not case-sensitive. |
/date |
No | Any date in the week. If omitted or empty, the current date is used. |
Result: the date of that weekday, as YYYY-MM-DD.
Examples
GetWeekDay /day=su /date-xpath=/my:myFields/my:StartDate
GetWeekDay /day=saturday /date-xpath=/my:myFields/my:StartDate /resultxpath=/my:myFields/my:DueDate
GetWeekDay /day=mo
For Friday 2026-10-09, the first returns Sunday 2026-10-04 and the second Saturday 2026-10-10. The third returns the Monday of the current week.
Notes
- Because the week starts on Sunday,
/day=mofor a Sunday date returns the next day: for2026-10-04it returns2026-10-05. For a Monday-to-Sunday week, handle Sundays separately (for example with DateAdd/days=-6). - The week may cross a year boundary:
/day=mofor2022-01-01returns2021-12-27. - Any time of day in
/dateis ignored. - Without
/date, "today" is the current date in UTC, which can differ from the user's local date late in the evening or early in the morning. GetDayOfYear uses the local date instead. When it matters, pass the date explicitly. - Errors: Invalid day parameter -- please use either a complete day name or two letter abbreviation, and Unable to parse date: followed by the value.
Related: GetDayOfYear, DateAdd.
4.7 Irr
Returns the internal rate of return for a series of periodic cash flows (payments as negative numbers, receipts as positive numbers). Use it in investment, capital request and business case forms.
Syntax
Irr /values=<n>,<n>[,<n>...] [/guess=<rate>]
| Parameter | Required | Description |
|---|---|---|
/values |
Yes | The cash flows, in period order, separated by commas. At least one must be negative and at least one positive. |
/guess |
No | Your estimate of the rate, as a decimal fraction. Default 0.1 (10 percent). |
Result: the internal rate of return, calculated by Qdabra Forms.
Example
Irr /values=-1000,300,400,500
Irr /values-xpath=/my:myFields/my:CashFlowList /guess=0.05
The first describes an investment of 1000 followed by three receipts; its internal rate of return is about 8.9 percent. The second reads the list from a text field.
Notes
- Write plain numbers only: no thousands separators, currency symbols or spaces inside a number. A comma always starts a new value, so
-1,000becomes the two values-1and000. Spaces around the commas are fine. - An empty entry (for example a trailing comma) counts as
0. - Give rates as decimal fractions (
0.05), not percentages:/guess=5%is read as5, which is 500 percent. - Errors: Values must contain at least one positive and one negative number, Invalid number: followed by the entry, and Value 'abc' for parameter 'guess' is not a valid number. for a guess that is not a number.
Related: Npv, FormatNumber.
4.8 Npv
Returns the net present value of a series of periodic cash flows at a given discount rate.
Syntax
Npv /rate=<rate> /values=<n>,<n>[,<n>...]
| Parameter | Required | Description |
|---|---|---|
/rate |
Yes | The discount rate per period, as a decimal fraction (for example 0.08 for 8 percent). |
/values |
Yes | The cash flows, in period order, separated by commas. At least one must be negative and at least one positive. |
Result: the net present value, calculated by Qdabra Forms.
Example
Npv /rate=0.08 /values=-1000,300,400,500
Npv /rate-xpath=/my:myFields/my:DiscountRate /values-xpath=/my:myFields/my:CashFlowList
The first discounts the four cash flows at 8 percent per period; the second takes the rate and the list from fields.
Notes
/valuesfollows the same rules as in Irr: plain numbers separated by commas, an empty entry counts as0, and at least one negative and one positive value are required, even though a net present value could be calculated without them./ratemust be a number: Value 'abc' for parameter 'rate' is not a valid number. As with/guess,8%is read as8(800 percent).- To show the result as money, pass it to FormatNumber with
/format=CorN2.
Related: Irr, FormatNumber.
Back to the Command Index.