Question
CBA
AU
Last activity: 7 May 2021 12:07 EDT
display the result in hours and mins
I have requirement to calculate the time difference between 2 dates Based on that I have to display the result in hours and mins Is there any OOTB function available I have tried DateTime difference but we can get either days or minutes or hours in that.
***Edited by Moderator: Pallavi to update platform capability tags***
-
Like (0)
Pavithra V Subham Divyansh Shivangee Kumari -
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Updated: 7 Jul 2020 21:25 EDT
Blue Rose Technologies
DE
Hi,
You can use the expression below,
round(@DateTime.DateTimeDifference(Param.StartTime,Param.EndTime,"h")) + ":" + (round(@DateTime.DateTimeDifference(Param.StartTime,Param.EndTime,"m")) - round(@DateTime.DateTimeDifference(Param.StartTime,Param.EndTime,"h")) * 60)
Please see example screenshots below,
Incessant Technologies Pvt.Ltd
AU
Hello,
There is no single function in pega that provide the result in Hours and Minutes at a time.You can try this approach if you want the results in Hours and Minutes.
1. Get the difference in minutes between the dates using DateTimeDifference(starttime,endtime,"m") function
2. Now divide the results with 60 which will give the result in hours
3. Now take the difference between the original number of minutes and 60* Number of hours obtained in 2nd step. This will give the delta minutes.
4. Concatenate both using Hours+"h:"+Delta_minutes+"m" and assign the result to a String value
-
Sam mk
CBA
AU
Thanks for the reply could you provide the screenshot if any, not able to understand the divide part.
Accepted Solution
Updated: 7 Jul 2020 21:25 EDT
Blue Rose Technologies
DE
Hi,
You can use the expression below,
round(@DateTime.DateTimeDifference(Param.StartTime,Param.EndTime,"h")) + ":" + (round(@DateTime.DateTimeDifference(Param.StartTime,Param.EndTime,"m")) - round(@DateTime.DateTimeDifference(Param.StartTime,Param.EndTime,"h")) * 60)
Please see example screenshots below,
-
Sam mk Jose Navas
CBA
AU
Thanks, much Shyju
SoftServe
US
Do something like this can be implemented for reports?
I noticed we already have the function pxConvertTimeUnits to convert from seconds to minutes, or from minutes to hours, etc. But what if we want to convert from seconds to hours-minutes? example: 3660 seconds will result in 1 hour, 1 min. Or maybe display minutes if the hour hasn't been completed, like displaying 30 minutes instead of 0.5 hours.
Thanks for considering my reply.
-Jose
Pegasystems Inc.
US
There is no OOTB function alias that will do this specific calculation and formatting. It would have to be implemented as a custom function alias. Note that function aliases can be nested (one function alias can call another) so this can probably be done mostly by calling OOTB FAs from the custom FA.
-
Jose Navas Anil Kumar
Areteans Technology
IN
Hi @Shyju ,
What if the time difference is less than 1 hr? this function will show 1:-25 which not expected.
we need to check minutes if it is Less than 60 or not .and then calculating this.
Thanks,
Sravan