Subtract months to a date custom field and populate another date field from the result

Hi, 

the requirement is to subtract months from a date a custom field and put the result in another date custom field. 

example

Datefield2 = Datefield1 - 10 months

I could subtract days only using script runner, any ideas?

Thanks, 

Flan

1 answer

This widget could not be displayed.

Hi Flan,

If you want the result in a scripted field then the script will br something like 

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def months = 3
def dateACF = customFieldManager.getCustomFieldObjectByName("First DateTime")
def dateAValue = issue.getCustomFieldValue(dateACF) as Date

def dateB = Calendar.getInstance()

dateB.setTime(dateAValue)
dateB.add(Calendar.MONTH, -months)
dateB.getTime()

with

Searcher: Date Time Range picker
Template: Date Time Picker

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

127 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you