It's all about the answers!

Ask a question

How do I programmatically get creation date of work item's as month and year?


Dulsanka Kulasinghe (3812) | asked Sep 14 '16, 10:54 a.m.
edited Sep 20 '16, 8:52 a.m.

Hi

I'm new to the RTC environment and I'm in a need of geting the "month" and the "Year" of a specific item based on its created date. can you please help me with a method and/or a script to get this done.

Thanks


Comments
1
Arne Bister commented Sep 15 '16, 1:52 a.m.
JAZZ DEVELOPER

Hi,
can you please specify what you are trying to achieve? Do you refer to "work items" when you say specific item? For those the displayed creation date shows month and year. So I assume you mean different items.
When you want to get month and year, do you want it displayed in a particular UI or do you want to run an external script which prints this info?

Please update the header of your request to become a question (e.g. "How do I programmatically get creation date of work items as month and year?") to increase chances for more people answering.

- Arne


Dulsanka Kulasinghe commented Sep 20 '16, 8:55 a.m.

Hi Aren

Thanks for your suggession, which I did change the heading.

As you understood, my requirement is to get the createtion month, creation Year of a work iteam (say incident) via the creation date of it.

My attempt is to, dispaly monthly/yearly figures on dashboard, based on that.

Thanks - Dulsanka

2 answers



permanent link
Donald Nong (14.5k614) | answered Sep 22 '16, 6:31 a.m.
A simple query will not work, as this sounds like a report. In this case, consider creating a BIRT report for this purpose.
https://www.ibm.com/developerworks/rational/library/10/creatingcustomreportswithbirtandrtc-part1/
https://www.ibm.com/developerworks/rational/library/10/creatingcustomreportswithbirtandrtc-part2/
http://www.ibm.com/developerworks/rational/library/10/creatingcustomreportswithbirtandrtc-part3/
http://www.ibm.com/developerworks/rational/library/create-custom-reports-birt-rtc/

permanent link
Dulsanka Kulasinghe (3812) | answered Oct 11 '17, 5:52 a.m.

Hi - was able to get the answer via enumes..

{
var cDate= dojo.date.stamp.fromISOString(workItem.getValue(WorkItemAttributes.CREATION_DATE));
if(!cDate)
{
cDate = new Date();
}

if (cDate.getMonth() == 0) {
return 'month.literal.l4'; // January
   }
if (cDate.getMonth() == 1) {
return 'month.literal.l6'; // Feb
}
if (cDate.getMonth() == 2) {
return 'month.literal.l8';
}
if (cDate.getMonth() == 3) {
return 'month.literal.l10';
}
if (cDate.getMonth() == 4) {
return 'month.literal.l12';
}
if (cDate.getMonth() == 5) {
return 'month.literal.l14';
}
if (cDate.getMonth() == 6) {
return 'month.literal.l16';
}
if (cDate.getMonth() == 7) {
return 'month.literal.l18';
}
if (cDate.getMonth() == 8) {
return 'month.literal.l20';
}
if (cDate.getMonth() == 9) {
return 'month.literal.l22';
}
if (cDate.getMonth() == 10) {
return 'month.literal.l24';
}
if (cDate.getMonth() == 11) {
return 'month.literal.l26'; // Dec
}
return 'month.literal.l2'; //unassigned
}

sharing s it might help anyone else who search for this kind of a solution.

DK

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.