"Hours" text not updating correctly.
I have four custom fields:
Date/Time Resolved (Date/Time Picker) customFieldId=10241 Date/Time Verified (Date/Time Picker) customFieldId=10242 MTTR (Single Line Text Field) MTTV (Single Line Text Field)
My workflows have many statuses, but only two really matter here.
On the Resolve transition, a tx screen appears where the user can update the "Date/Time Resolved" field and I have an advanced parsed text post function to update MTTR by comparing the created date and the Date/Time Resolved field on this transition. Here is the formula:
floor((datePart({10241}, LOCAL) - datePart({00009}, LOCAL)) / {DAY}) + "days " + (modulus(datePart({10241}, LOCAL) - datePart({00009}, LOCAL), {DAY}) / {HOUR}) + " hours"
The next transition window allows you to update "Date/Time Verified" field. On the transition the same kind of post function compares the "Date/Time Resolved Field" and the "Date/Time Verified Field" and populates the value to the MTTV field. Here is the formula: floor((datePart({10242}, LOCAL) - datePart({10241}, LOCAL)) / {DAY}) + "days " + (modulus(datePart({10242}, LOCAL) - datePart({10241}, LOCAL), {DAY}) / {HOUR}) + " hours"
Everything seems to be working correctly. However, the hours field is no longer updating it just sits at 0 for both MTTR and MTTV fields. When I was just updating the MTTR field with instructions provided by you, everything worked fine and hours were updating correctly as well as days. However as soon as I tried to do this on my own this happened! lol plz help.
Comments (5)
-
repo owner -
Account Deactivated reporter Thank you so much Fidel! Do I update both of my formulas, or just one?
-
repo owner Yes, Robert, you should also modify your second expression. Assuming that Date/Time Verified is always greater (later) than Date/Time Resolved, then your expression should be:
floor(({10242} - {10241}) / {DAY}) + " days " + toString(modulus(({10242} - {10241}), {DAY}) / {HOUR}, 2) + " hours"
-
repo owner - changed status to resolved
-
repo owner Issue
#430is related to this one. - Log in to comment
Hi Robert,
The problem with the current expression you are using is that function datePart() is rounding dates to whole days, and for that reason the hours term is always zero.
Use this expression instead:
I have also included function toString() in order to limit the number of decimals for the hour term to 2.