Good Day
I have a rdlc report on my time and attendance solution, but the totals field keeps giving me the wrong value...
=IIF(((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).Minutes.ToString().Length=1,string.Format("{0}:0{1}",Convert.ToInt32(((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).TotalHours),((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).Minutes),string.Format("{0}:{1}",Convert.ToInt32(((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).TotalHours),((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).Minutes))
This is the expression for the Total field...
What am I doing wrong?
Thanks in advance
It was a noob mistake 😅
I made a test program to illustrate The solution
the total hours from 8:37 came to 8.61666666666667 converting it to an int came to 9 but casting it to an int gave me the desired 8
But when applying this to rdlc report, casting (int)
wouldn't work... So I used Math.Truncate
=IIF(((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).Minutes.ToString().Length=1,string.Format("{0}:0{1}",Math.Truncate(((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).TotalHours).ToString("F0"),((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).Minutes),string.Format("{0}:{1}",Math.Truncate(((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).TotalHours).ToString("F0"),((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).Minutes))
Hope This Could Help Someone!