Our new Appfire Documentation Space is now live!

Take a look here! If you have any questions please email support@appfire.com

Add certain number of minutes/hours/days/weeks/months to a date

Abstract

This code snippet adds a certain number of minutes/hours/days/weeks/months to a Date/Date-Time picker field.

Logic

Add the number of minutes/hours/days/weeks/months to the date field using Use(TimeCategory

Snippet 

use (groovy.time.TimeCategory) {
     return <Date Object> + <Number of units>.<Unit>
 }

Placeholders

PlaceholderDescriptionExample
<Date Object>Access a date fieldissue.get("created")
<Number of units>
The number of units to be added5
<Unit>is one of "minutes","hours","days" "weeks" or "months"months

Examples

The output of this code snippet is a Timestamp which you could use in a Groovy expression, for example to:

  • Set a date field to issue created plus 5 days

    use (groovy.time.TimeCategory) {
         return issue.get("created") + 5.days
     }
  • Set "Planned Delivery Date" as 1 month from today

    use (groovy.time.TimeCategory) {
         return new Date() + 1.month
     }

References