How to generate next monday based on today's date?

Given a DateTime variable, how to find next Monday in customScript actions?

Say that this script is only to run on Fridays, and I want the next Monday. I’ve tried the following:

@CustomScriptAction(
output = 'monday'
)

def customScript(){
RDateTime.now().plus(java.Duration.ofDays(3))
}

and

def customScript(){
RDateTime.now().plusDays(3)
}

Which should be valid expressions.

Hi Jonathan,

You need to use java.time.Duration.ofDays

You can find similar samples of custom scripts in this topic

Hi Team,

I have to get previous day’s date.
If
previous day is Saturday or sunday ,then I should get Thursday’s date
else
if previous day is a business working day(Monday , Tuesday , Wednesday , Thursday , Friday ) then I should get previous day’s date only.

Please help me on this .

Thanks in advance.

@ravikumar177 follow the link above. You will find scripts to get the day of the week and calculate a new date there.
You workfliw will look as follows:

  • calculate yesterday’s date
  • get its day of week
  • if it is Sunday, subtract 3 days
  • it it is Saturday, subtract 2 days
  • otherwise, do nothing

Could you please share the code .
That will help me a lot.

Thanks in advance.

Here it is
calculating_date.zip (936 Bytes)

Thank you so much @ashapkina
:blush: