Date time calculation

I have 2 attributes start date and end date . I want to show difference between start date and end date in HH:mm format in text box. I used hoursbetween function to get the difference of start and end date. It just gives me hours then how will I achieve minutes also ? In this format - HH:mm ?
2 answers

You could try this:

- use floor(minutesBetween($start, $end)) to get $duration in minutes as an integer

- use floor($duration : 60) to get $hours

- use $duration mod 60 to get remaining $minutes

- use the StringLeftPad java action in CommunityCommons to format toString($hours) and toString($minutes) as a two character string with leading zeroes if necessary

- finally concatenate using $leftpaddedHours + ':' + $leftpaddedMinutes


Edit: you could also do the following:

minutesBetween($start, $end) as $duration

formatDecimal(floor($duration : 60), '00') + ':' + formatDecimal(floor($duration mod 60), '00')


Hey Shailja, since you also want the number of minutes, I'd suggest using minutesBetween the two dates and then formatDateTime($minutesBetween, 'HH:mm').