Hi,
I would like to know if there is an easy way of getting a time interval value translated in second (maybe a interval SIL function/routine for example).
Right now I am getting the interpretative value (1d 3h 15min) in my custom field but I cannot do any calculation with it when data fields are exported to excel for instance.
Here is the code example I am using:
string [] subtasks = subtasks(key);
interval subtaskTimeSpentTesting;
for(string task in subtasks){
subtaskTimeSpentTesting = subtaskTimeSpentTesting + getTimeSpent(task, "hses-testing-group");
}
return getTimeSpent(key, "hses-testing-group") + subtaskTimeSpentTesting;
Thank you in advance for your help.
I'am using this code to convert interval to number type:
function dateToSeconds(date dateToConvert) { number seconds; number year = formatDate(dateToConvert, "yyyy"); number day = formatDate(dateToConvert, "D"); number hours = formatDate(dateToConvert, "H"); number minutes = formatDate(dateToConvert, "m"); number sec = formatDate(dateToConvert, "s"); seconds = year*365*24*60*60 + day*24*60*60 + hours*60*60 + minutes*60 + sec; return seconds; } function countWeekends(date dat1, date dat2) { number countD = 0; dat1 += "1d"; while (dat1 < dat2) { if (dayOfWeek(dat1) == "Sun" || dayOfWeek(dat1) == "Sat") countD +=1; dat1 += "1d"; } return countD; } string field_name = "status"; string[] field_history = fieldHistory(key, field_name); number n = arraySize(field_history); date date1; date date2; number finalResult = 0; for (number i = 1; i< n; i += 2) { if (i!=(n-1) && field_history[i] == 3) { date1 = parseDate("yyyy-MM-dd HH:mm:ss",field_history[i-1]); date2 = parseDate("yyyy-MM-dd HH:mm:ss",field_history[i+1]); finalResult += - countWeekends(date1,date2)*8*60*60; finalResult += dateToSeconds(date1 + toRawWorkingInterval(date2-date1))-dateToSeconds(date1); } } return finalResult/60/60;
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.