Is thete any "week" custom field?

Hello people,

is there any week custom field available in JIRA, or some add-on for that?

I would like to have a field where I can select a calandar date (ie: Feb/19th/2014) and the field stores W7 value, or Week7.

Of course I can create a select list with W1 - w53, but users will be confusing.. because they need to convert their dates into week format manualy.

thanks

1 answer

1 accepted

Hi,

Nice question, This can be done,

How are we going to achieve ?

You will be having a datepicker custom field and you need to create a select list with W1 - w53, in datepicker customfield we are going to add a javascript, which will automatically select the week.

But You have to add javascript.Please check the below javascript.

These code which are below will come inside the date picker custom field .This is for getting the week

Date.prototype.getWeek = function () {

// Create a copy of this date object

var target = new Date(this.valueOf());

// ISO week date weeks start on monday

// so correct the day number

var dayNr = (this.getDay() + 6) % 7;

// ISO 8601 states that week 1 is the week

// with the first thursday of that year.

// Set the target date to the thursday in the target week

target.setDate(target.getDate() - dayNr + 3);

// Store the millisecond value of the target date

var firstThursday = target.valueOf();

// Set the target to the first thursday of the year

// First set the target to january first

target.setMonth(0, 1);

// Not a thursday? Correct the date to the next thursday

if (target.getDay() != 4) {

target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7);

}

// The weeknumber is the number of weeks between the

// first thursday of the year and the thursday in the target week

return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000

}

This is for getting the week from datepicker customfield and setting it in the week customfield

$("#datecustomfield").change(function(){

var today = $("#datecustomfield").getDate();

var week = "W"+today.getWeek();

$("#weekcustomfield option[text="+week+"]").attr("selected","selected");

});

Hope this helps you!

Thank you Nitram. I did not test it yet, but I got the idea.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,755 views 11 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot