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

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

Abstract

This code snippet adds a certain number of minutes/hours/days/weeks/months to a date 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

Placeholder

Description

Example

Placeholder

Description

Example

<Date Object>

Access the date field

issue.get("created")

<Number of units>

The number of units to be added

5

<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:

  • Calculate and display the issue creation plus 5 days in a Calculated Date/Time field

    use (groovy.time.TimeCategory) { return issue.get("created") + 5.days }
  • Calculate and display the issue Due Date minus 3 months in a Calculated Date/Time field

    use (groovy.time.TimeCategory) { return issue.get("duedate") ? issue.get("duedate") - 3.months : null }

References

Related articles

Need support? Create a request with our support team.

Copyright © 2005 - 2026 Appfire | All rights reserved.