It's all about the answers!

Ask a question

Export Date not Timestamp when exporting using RPE


Ben Sharples (811950) | asked Nov 09 '16, 9:17 a.m.
I have fields in RQM where I am assigning a Date to a Test Case and when I export to RPE I want to display only the date - preferably in a UK style format dd/mm/yyyy.

However in RPE it always displays the a timestamp as well as the date in us format yy/mm/dd.

Is there a way to change this without having to use Java Script to parse and split the string up before re-assembling with just the informaiton I am interested in exporting.


One answer



permanent link
Subramanya Prasad Pilar (4.6k14) | answered Nov 09 '16, 11:23 p.m.
edited Nov 10 '16, 12:20 p.m.
If you are printing the date (dateTime) in a Text element, set Date pattern (in Properties->Specific tab for the Text element) property.
As an alternate, you can use a JavaScript function to change the date format. These functions can be readily found in .js files under %rpe_home%\utils\scripts, if you are using RPE 2.1 or later. Here is a sample function:
//function to change date format to "MMM dd, yyyy"
function changeDateFormat(date)
{
    try
    {
        var currDtFmt = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    var curDt = currDtFmt.parse(date);
    var expDtFmt = new java.text.SimpleDateFormat("MMM dd, yyyy");
    var dateString = expDtFmt.format(curDt).toString()
    _sessionLogger.info("##### data string: " + dateString);
    return dateString;
    }
    catch(err)
    {
        java.lang.System.out.print( err);
    return date;
    }
}

Comments
Ben Sharples commented Nov 10 '16, 7:24 a.m.

Propoerties changes doesn't work. (I suspect because I have to grab the value, assign it to a variable and then print the variable.)

I'm working with RPE 1.3 - and there's nothing in the utils folder. Is there somewhere else I can find these javascript functions?


Subramanya Prasad Pilar commented Nov 10 '16, 12:23 p.m.

I ran a quick test and just setting Date format to yyyy-MM-dd works fine.




However, setting it to yyyy-MM-dd returned incorrect date.

Your answer


Register or to post your answer.