Converting total time in integer into HH:MM format

2020-07-30 02:27发布

问题:

I am using below given formula to change 3.50 hours to 03:30(HH:MM) format in crystal report but it showing 04:30(1 hr added automatically)

numbervar totalHours:=ToNumber({Table.ExtraHoursOn1});
numbervar totalminutes:=ToNumber({Table.ExtraHoursOn1})*60 mod 60;
ToText(totalHours,0)+':'+
ToText(totalminutes,'00')

I don't know where i am getting wrong.

回答1:

This is the right syntax for changing the format, truncate function was missing

numbervar totalHours:=ToNumber({Table.ExtraHoursOn1});
numbervar totalminutes:=ToNumber({Table.ExtraHoursOn1})*60 mod 60;
ToText(Truncate(totalHours),0)+':'+
ToText(totalminutes,'00')