Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


UI Text Box
sizemedium
typeinfo

This functions subtracts two timestamps (the second date will be substracted from the first date) ignoring the weekends.

This way you can easily calculate the elapsed working time since weekends will be ignored.


Code Block
languagebash
titleSyntax
linenumberstrue
subtractDatesSkippingWeekends(firstDate, dateToSubstract, timeZone) #Output: Number


UI Expand
titleExamples


Parser expressionDescription


Code Block
linenumberstrue
subtractDatesSkippingWeekends({issue.resolutionDate}, {issue.created}, LOCAL)


This example calculates the elapsed working time from issue creation to resolution

The result will return milliseconds.


Code Block
linenumberstrue
round(subtractDatesSkippingWeekends(({issue.resolutionDate}, {issue.created}, LOCAL)/{HOUR})


This example returns the hours instead of milliseconds.

Additional useful functions can be found here: Numbers



UI Expand
titleAdditional information

Parameters used in this function

ParameterInput (data type)Description
firstDate

Status
subtletrue
titlenumber

The parameter must be valid timestamp. Usually this value is retrieved from a field (e.g. due date, created date).
dateToSubstract
Page properties
hiddentrue
Status
Tech review

Status
titletodo

Style guide

Status
titletodo

Status
titletodo
Status
colourYellow
titleReady for review
Status
colourGreen
titledone
Status
colourRed
titleflagged

Page properties
hiddentrue
Short descriptionReturns a 

Status
subtletrue
titlenumber

representing a timestamp equivalent "minuend_date - subtrahend_date" subtracting weekend periods from the result.Output

The parameter must be valid timestamp. Usually this value is retrieved from a field (e.g. due date, created date).

timeZone

Status
subtletrue
title

timezone

The time zone used for the conversion. 

number



ui-text-boxexpand
sizetitlemedium
typeinfo
Output

This function returns a

Returns a 
Status
subtletrue
titlenumber
representing a timestamp equivalent "minuend_date - subtrahend_date" subtracting weekend periods from the result. i.e., you get the elapsed working time from subtrahend_date to minuend_date representing a timestamp.


UI Text Box
typetip

Work days might depend on the time zone - it might be Sunday on the west coast of the US while at the same time it's already Monday in Australia. 




UI Text Box
sizemedium
typeinfo

Variant of the function where you can additionally define the start and the end of the weekend.

This function is useful when the non-working days differ from the standard (Saturday/Sunday).


Code Block
languagebash
titleSyntax
linenumberstrue
subtractDatesSkippingWeekends(number minuend_datefirstDate, dateToSubtract, number subtrahend_date, timeZone time_zonetimeZone, startOfWeekend, endOfWeekend) #Output: Numbernumber


UI Expand
titleExamples


Parser expressionDescription


Code Block
languagebash
linenumberstrue
subtractDatesSkippingWeekends({issue.resolutionDate}, {issue.created}, LOCAL, {FRIDAY}, {SATURDAY})


This example calculates the elapsed working time from issue creation to resolution using an Arabic weekend.

The result will return milliseconds.


Code Block
languagebash
linenumberstrue
round(subtractDatesSkippingWeekends({issue.resolutionDate}, {issue.created}, LOCAL, {FRIDAY}, {SATURDAY})/{DAY})


This example returns the full days instead of milliseconds.

To achieve this the {DAY} time macro and the round()function are used.

Additional useful functions can be found here: Numbers



UI Expand
titleAdditional information

Parameters used in this function

ParameterInput (data type)Description
<parameter>firstDate

Status
subtletrue
titledata type

Parameter description.

number

The parameter must be valid timestamp. Usually this value is retrieved from a field (e.g. due date, created date).
dateToSubtract<parameter>

Status
subtletrue
titledata typenumber

The parameter must be valid timestamp. Usually this value is retrieved from a field (e.g. due date, created date)Parameter description.

timeZone

Status
subtletrue
titletimezone

The time zone used for the calculationconversion

Expand
titleLearn more about timezones
Excerpt Include
Dates, times and time zonesDates, times and time zones
nopaneltrue
startOfWeekend

Status
subtletrue
titlenumber

The parameter will take values in the format of {MONDAY},{TUESDAY}...{SUNDAY}
endOfWeekend

Status
subtletrue
titlenumber

The parameter will take values in the format of {MONDAY},{TUESDAY}...{SUNDAY}



UI Expand
titleOutput

This function returns a

Status
subtletrue
titlenumber
 representing a timestamp.


UI Text Box
typetip

Work days might depend on the time zone - it might be Sunday on the west coast of the US while at the same time it's already Monday in Australia. 

The output can be written into any number field.

Another very common use case is to use this function in a JWT calculated date-time fields. If you don't want to work with milliseconds check out all available time macros.

If you want to simply add days to a timestamp you might want to have a look at the function addDaysSkippingWeekends().

Not sure what this function returns?  Simply test your expression on the expression parser test page.



Image AddedUse cases and examples

Page properties report
firstcolumnUse case
headingsJWT feature, Workflow function, Field type, Automated action, Parser functions
cqllabel = "parser_func_subtractdatesskippingweekends" and space = currentSpace()


Page properties
hiddentrue
id1


Parser function cloud
Map(question)
Notes

Workaround

Code Block
languagebash
let now  = new Date();
now = now.minusHours(12);
now = now.minusMinutes(15);
now.getDay()==0? now.minusDays(1):(now.getDay()==6? now.minusDays(2): now)//Skip weekends





Page properties
hiddentrue



Status
Tech review

Status
colourGreen
titledone

Style guide

Status
colourGreen
titledone

Status
titletodo
Status
colourYellow
titleReady for review
Status
colourGreen
titledone
Status
colourRed
titleflagged



number
Page properties
hiddentrue


Short description

Subtracts two timestamps ignoring the weekends.

Output

Status
subtletrue
titlenumber

Available since

Status
subtletrue
colourBlue
title2.2.7

Label
UI Expand
titleOutput
The function returns a
Status
subtletrue
title