I've created a date calculation (start and end dates as separate fields), but need to return a result of hours / days.
I've got it to display the result, but need it to show whether this is in days or hours. The calculation gives a result in either days or hours, based on how long between start and end, but I need text to show which is being used - for example, 5 hours, or 4 days.
This is my calculation so far:
var end = moment(@End Date of absence);
var start = moment(@Start Date of absence);
var days = end.diff(start, "d");
var hours = end.diff(start, "hours");
var check = days >= 1 ? days : hours;
How do I include the word "hours" or "days" in the calculation? I know I'd likely need to change the calculation type to text rather than number, but can I just put
var check = days >= 1 ? days "days" : hours "hrs";
Or do I need to put something else?
If possible, I'd really like it to display in hours AND days - for example we have someone who left at 1pm and was off for 2.5 days but it is showing 2 days. However - that's going to be awkward with the difference between working hours and hours in a day.
Thanks in advance - just trying to tidy it up a bit to make it obvious to the person who will be using this data.
Please sign in to leave a comment.