Relative Dates :

0
  • Friday, April 13, 2012

  • When you add actual dates to a filter, they are really only useful when the filter is used. If you want to save the filter for later use, you probably will need to modify the date each time you use it.

    To solve this issue, date fields also allow you to enter relative dates, which reflect the time they are used.

    Relative Dates : [m D] {1..N} where :
    •m is the multiplier and
    •D is displacement : Year / Month / Week / Day / Hour / MINute / Second

    Other options: now / today / yesterday


    Example 1: create a filter that shows a data for all issues that were entered more than 1 year 33 days -44 minutes from the time the filter is run.

    Date Entered > -1 Y -13days +44 Min

    Example 2: Find all issues that were closed in the last month.

    Close Date > -1 month

    Metrics : Finding the duration of time that an issue was in a specific status.

  • Tuesday, March 27, 2012
  • A number of customers have expressed interest in finding ways to provide metrics, using the history information that is recorded in issues. The best way to achieve this is to create a custom field to define the information you are looking for (it can be hidden if desired). Then the contents of this field can be accessed in issue details and ultimately in reports. The following classes can be used for advanced user defined fields :

    • FormulaDateCustomUserField - end result is a date value
    • FormulaCustomUserField - end result is a numeric value
    • FormulaIntCustomUserField - end result is an integer value
    • FormulaStringCustomUserField - end result is a text value


    To use any of these classes, you must provide an OGNL formula (see Rank documentation), which is used to retrieve data from the issue history. This formula allows you to access values and methods for the internal BugStruct class for each issue. Some valueable methods for metrics include :

    • // finds the date that the issue was changed FROM a value for a specified field
    • // or (last=true) the last time it changed FROM that value
    • dateChangedFrom(int fieldId, String value1, boolean last)

    • // finds the date that the issue was changed to a value for a specified field
    • // if value2 is not null, it finds when the issue changed from value1 to value2.
    • // or (last=true) the last time it changed to that value
    • // if value1 is null, this will just return when the field was changed (to any value)
    • dateChangedTo(int fieldId, String value1, String value2, boolean last)
    • dateLastChangedTo(int fieldId, String value1, String value2)

    • // find the time taken for an issue to move from one value to another
    • // fieldId : the id of the field holding the desired value. (Reference ids in custom field setup)
    • // Note: custom fields are > 100, default fields <100)
    • // format may take the form of "m", "h", or "d" for (months, hours, or days)
    • elapsedTimeBetweenStates(int fieldId, String value1, String value2, String format)
    • elapsedTimeBetweenDates(Date d1, Date d2, String format)

    I will look at a few examples that have come up in the past few months :

    Example 1: Time taken to move from status A to status B

    - Find the id (SID) of the field that holds the status you are interested in.
    - Define a custom field called TimeTakenAB using the "custom" advanced field option as follows:

    • Custom Class : com.other.FormulaIntCustomUserField
    • Custom Class Formula: elapsedTimeBetweenStates(SID, "A", "B", "d")

    The TimeTakenAB field should now show the number of days that each issue took to move from state "A" to state "B". A value of 0 is given for issues where the states were not found.

    Example 2: Which issues had a field changed to XYZ during the last week.
    - Find the id (SID) of the field that holds the values you are interested in.
    - Define a custom field called DateChangedToXYZ using the "custom" advanced field option as follows:

    • Custom Class: com.other.FormulaDateCustomUserField
    • Custom Class Formula: dateChangedTo(SID, XYZ, null, true)
    • (alternatively) dateLastChangedTo(SID, XYZ, null)

    - The DateChangedToXYZ should then display the desired date.

    Example 3: How many issues were fixed in the last 4 Weeks

    - Find the id (SID) of the status field is 20.
    - Define a custom field called DateFixed using the "custom" advanced field option as follows:

    • Custom Class : com.other.FormulaDateCustomUserField
    • Custom Class formula : dateChangedTo(5,"Fixed")

    - Create a filter that uses a relative date ( ie: DateFixed <= -4 weeks) on this new field. The results should only include the issues you are looking for and the field is available in the details section also.