Search code examples
crystal-reports

Converting total time in integer into HH:MM format in crystal report


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.


Solution

  • 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')