Versions Compared

Key

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


UI Text Box
sizemedium
typeinfo

This function adds or subtracts natural days (or working days) to or from any given date.

Weekends will notbecounted as working days.


Code Block
languagebash
titleSyntax
linenumberstrue
addDaysSkippingWeekends(timestamp, numberOfDays, timeZone) #Output: Number


UI Expand
titleExamples


Parser expressionDescription


Code Block
linenumberstrue
addDaysSkippingWeekends({issue.dueDate}, 2, LOCAL)


This example adds 2 working days to the issue's due date. 

  • If the due date is set to a Monday the function will return a date-time for Wednesday.
  • If the due date is set to a Friday the function will return a date-time for Tuesday.


Code Block
linenumberstrue
addDaysSkippingWeekends({issue.dueDate}, -2, LOCAL)


This example subtracts 2 working days from the issue's due date.

  • If the due date is set to a Monday the function will return a date-time for Thursday.
  • If the due date is set to a Friday the function will return a date-time for Wednesday.
Page propertiesStatusTech review

Status
titletodo

Style guide

Status
titletodo

Status
titletodo

Status
colourYellow
titleReady for review

Status
colourGreen
titledone

Status
colourRed
titleflagged

Page properties
hiddentrue
Short descriptionTimestamp equivalent of any given day plus an offset of n days where weekends don't count.Output

Status
subtletrue
titlenumber

UI Text Box
sizemedium
typeinfo

Status
subtletrue
titleTimestamp
equivalent of any given day plus an offset of n days where weekends don't count.

Syntax


Code Block
linenumberstrue
addDaysSkippingWeekends
t
({issue.cf10100}, 
n
-6, 
time
USER_
zone)
UI Text Box
typeinfo

If represents a timestamp which coincides with a Friday, adding n = 1 will return a date-time for the following Monday.

Negative values for are used in order to subtract days to t.

UI Text Box
typenote

Noten cannot be higher than 50000.

Input

ParameterData typeDescription
LOCAL)


This example subtracts 6 working days from of a custom date-time field (with the ID 10100).

Instead of the Jira server's local time, this example uses the current user's time zone.



UI Expand
titleAdditional information

Parameters used in this function

ParameterInput (data type)Description
timestamp
t

Status
subtletrue
titlenumber

timestamp returned by a custom field or 
The parameter must be valid timestamp. Usually this value is retrieved from a field (e.g. due date, created date).
numberOfDays
n

Status
subtletrue
titlenumber

Number of days to be added

The offset in days. Negative values are used to subtract days.

Internally JWT multiplies this value with the time macro {DAY} to add full days to the timestamp. Learn more about time macros.

timeZone
time_zone

Status
subtletrue
titletimezone

Timezone which will be used to base the calculation on

The time zone used for the calculation. 


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 Expand
titleOutput

This function returns

Output

This expression will return a timestamp as

Status
subtletrue
titlenumber
 representing a timestamp




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
addDaysSkippingWeekends(timestamp, numberOfDays, timeZone, startOfWeekend, endOfWeekend) #Output: Number


UI Expand
titleExamples


Parser expressionDescription


Code Block
timeInStatus("Open", "my_schedule", LOCAL)
Number of milliseconds the current issue has stayed in status "Open" within the schedule called "my_schedule" matching the server's default timeZone.Syntax
linenumberstrue
addDaysSkippingWeekends({issue.dueDate}, 10, LOCAL, {FRIDAY}, {SATURDAY})


This example adds 10 working days to the issue's due date.

Fridays and Saturdays are not counted and will be skipped..


Code Block
linenumberstrue
addDaysSkippingWeekends({issue.dueDate}, -2, LOCAL, {SUNDAY}, {TUESDAY})


This example subtracts 2 working days from the issue's due date.

Sundays, Mondays and Tuesdays are not counted and will be skipped..



UI Expand
titleAdditional information

Parameters used in this function

ParameterInput (data type)Description
timestamp
Code Block
addDaysSkippingWeekends t, n, time_zone)
Info

If represents a timestamp which coincides with a Friday, adding n = 1 will return a date-time for the following Monday.

Negative values for are used in order to subtract days to t.

(warning) Noten cannot be higher than 50000.

Input data type(s)t: 

Status
subtletrue
titlenumber

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

Status
subtletrue
titlenumber

 representing the number of days

The offset in days. Negative values are used to subtract days.

Internally JWT multiplies this value with the time macro {DAY} to add full days to the timestamp. Learn more about time macros.

timeZone

Status
subtletrue
titletimezone

The time zone used for the calculation. 

startOfWeekend

Status
subtletrue
title

number

Valid values are {MONDAY}{TUESDAY} ... {SUNDAY}.
endOfWeekend
timezoneOutput

Status
subtletrue
titlenumber

Valid values are {MONDAY}{TUESDAY} ... {SUNDAY}.


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. 

Examples



UI Expand
title
Show examples
Code Block
timeInStatus("Open", "my_schedule", LOCAL)

Number of milliseconds the current issue has stayed in status "Open" within the schedule called "my_schedule" matching the server's default timeZone.

Code Block
timeInStatus("Open", "my_schedule", LOCAL)

Number of milliseconds the current issue has stayed in status "Open" within the schedule called "my_schedule" matching the server's default timeZone.

Code Block
timeInStatus("Open", "my_schedule", LOCAL)
Number of milliseconds the current issue has stayed in status "Open" within the schedule called "my_schedule" matching the server's default timeZone.
Output

This function returns a 

Status
subtletrue
titlenumber
 representing a timestamp


UI Text Box
typetip

The output can be written into any Jira field of type Date Picker ore Date Time Picker.

Another very common use case is to use this function in one of the JWT calculated date-time fields.

If you want to subtract two date-time values you might want to have a look at the function subtractDatesSkippingWeekends().




Image AddedUse cases and examples

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


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



Page properties
hiddentrue


Short descriptionAdds or subtracts natural days (or working days) to or from any given date.
Output

Status
subtletrue
titlenumber

Available since

Status
subtletrue
colourBlue
title2.2.7

Label

Status
colourRed
titlestaff pick