You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi Team,
I have implemented one script for calculating Number Of Weeks, see below:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import java.util.Date.*
import static java.lang.Math.*
import java.sql.Timestamp
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def dateFieldObject= customFieldManager.getCustomFieldObject('customfield_18880');
def dateFieldObject2= customFieldManager.getCustomFieldObject('customfield_12110');
if(issue.getCustomFieldValue(dateFieldObject) && issue.getCustomFieldValue(dateFieldObject2)) {
def dateValue= issue.getCustomFieldValue(dateFieldObject) as Date
def dateValue2= issue.getCustomFieldValue(dateFieldObject2) as Date
def diffdate = dateValue - dateValue2
double noofweeks = diffdate/7
double roundNoOfWeeks = Math.round(noofweeks)
int value = (int) roundNoOfWeeks;
return value
}
Now the user need some modification in it,
as
Number Of weeks(Calculated)= Today's date (NOW)- End Date ?
And if End date is reached, then (End date – Start date).
I have tried but not able to get the Today's date from the script.
Kindly please help me out to reach the modifications in the script.
Regards,
Neeta Jain
Hi @neeta jain
You can get current date in script using below snippet
today = new java.sql.Timestamp(new Date().getTime())
using this you can compare today's date with end date and do the calculation
BR,
Leo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.