The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Problem:
I need the issue statistics or 2-dimensional statistic dashboard gadget to group by date. For our current need, the calendar gadget will not work.
Due to this, I'm trying a workaround where I copy the date from a date field and create a label. When I copy from the field, the problem is that it creates 3 labels; the date, the time (12-hour format), and AM/PM. I only want the date to be copied.
Is there a way on a post-function script that ScriptRunner could copy just the date to the custom label field?
Hi @Matt Noe you can use the java date routines in scriptrunner.
This example was used to trigger a script in a job that would publish a report to confluence from jira but it's a good example of using the date functions:
import java.text.SimpleDateFormat
import java.sql.Timestamp
import java.text.DateFormat
import java.util.Date
// retrieve details of the current date so that we can run at midnight first day of month against prior month
def cal = Calendar.instance;
def currentYear = cal.get(Calendar.YEAR);
def currentMonth = cal.get(Calendar.MONTH);
// set the month instance to the start of the previous month
if ( currentMonth == 0 ) {
cal.set(currentYear-1, 11, 1);
} else {
cal.set(currentYear, (currentMonth-1), 1); // comment this line to run the report mid-month for current month
//cal.set(currentYear, (currentMonth), 1); // uncomment this line run the report mid-month re:remove the -1 from (currentMonth-1)
}
// extract the date, and format it to a string
Date previousMonthStart = cal.time;
String previousMonthStartFormatted = previousMonthStart.format('yyyy-MM-dd');
String previousMonthStartFormattedwithName = previousMonthStart.format('MMM-yyyy');
def today = new Date().format('MMM-dd-yyyy'); //for mid-month report run
Here's anther example in the Scriptrunner library
Hope this helps.
👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.