Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 to convert into hours and mins

Author  Topic 

shm
Yak Posting Veteran

86 Posts

Posted - 2009-01-15 : 03:06:49
hi,

in report designer (rdl),am doing some conversion

Hours worked column has a code "=(Fields!TotalHours.Value)" which is giving 111.60 which is correct

Footer has a sum, i need to change this code "=sum(Fields!TotalHours.Value)" which contains 111.60 i need to make it to 112.00 only when the decimal value is 0.60, if its less, need to show as it is

in the Report Properties--code i have used these two function

i got these function in this forum only

Public Function ConvertToMinutes (byVal paramHour as decimal) AS Integer

Return FLOOR(paramHour) * 60 + (paramHour mod 1) * 100.0

End Function


Public Function ConvertToHours (byVal paramMinutes as Integer) AS decimal

Return CDEC(TRIM(STR(INT(paramMinutes / 60))) & "." & TRIM(STR(paramMinutes mod 60)))

End Function


Then in the total sum field
= Code.ConvertToHours( SUM( Code.ConvertToMinutes( Fields!TotalHours.Value ) ) )


i tried this but it is giving error

for the 111.60 it is giving 112.40 and for the 260.50 it is giving
261.30 it should come as it 260.50



SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-15 : 03:24:35
[code]Public Function ConvertToMinutes(ByVal ParamHour As Decimal) As Integer

On Error Resume Next
Return 60 * Floor(ParamHour) + 100 * (ParamHour - Floor(ParamHour))

End Function

Public Function ConvertToHours(ByVal ParamMinutes As Integer) As decimal

On Error Resume Next
Return CStr(ParamMinutes \ 60) & "." & CStr(ParamMinutes Mod 60)

End Function[/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

shm
Yak Posting Veteran

86 Posts

Posted - 2009-01-15 : 03:42:57
hi

no it is coming the same error means value is wrong again it is coming 261.30 for 260.50 and 112.40 for 111.60
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-15 : 04:20:41
The two function above will work.

Tried these two in Excel and they work
Option Explicit
Function ConvertToMinutes(ByVal ParamHour As Currency) As Integer

On Error Resume Next
ConvertToMinutes = 60 * Int(ParamHour) + 100 * (ParamHour - Int(ParamHour))

End Function
Function ConvertToHours(ByVal ParamMinutes As Integer) As Currency

On Error Resume Next
ConvertToHours = Int(ParamMinutes / 60) + (ParamMinutes Mod 60) / 100

End Function

Rewrite as
Public Function ConvertToMinutes(ByVal ParamHour As Decimal) As Integer

On Error Resume Next
Return 60 * Int(ParamHour) + 100 * (ParamHour - Int(ParamHour))

End Function

Public Function ConvertToHours(ByVal ParamMinutes As Integer) As Decimal

On Error Resume Next
Return Int(ParamMinutes / 60) + (ParamMinutes Mod 60) / 100

End Function



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-17 : 02:59:35
what about this
=Cieling(Val(Fields!TotalHours.Value)-0.50)
Go to Top of Page
   

- Advertisement -