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

flan elflani September 11, 2017

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

Suggest an answer

Log in or Sign up to answer
1 vote
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 15, 2017

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

TAGS
AUG Leaders

Atlassian Community Events