Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one field hours

hours value will be timespan it means Day.Hour:Minute:Second

I want only hours from "hours" field but including day also.

For Ex.
if hours value is 1.12:10:00
output should be 24+12=36 hours

What I have tried:

I have tried
VB
=(Day(Fields!hours.value)*24)+(Fields!hours.Value)


but it is not working
Is there any solution?
Posted
Updated 27-Mar-19 23:37pm
v3
Comments
BillWoodruff 26-Nov-17 1:00am    
How is it not working ? Error ? Result that makes "no sense" ?

Looks to me like your code is multiplying hours by #24

AS Bill Woodruff noted, you are multiplyin g the hours by 24, then adding the hours to that, effectively yielding, hour times 25. You need to extract the days times 24, then add hours to that.
 
Share this answer
 
If hours field holds TimeSpan value, then you can use TimeSpan.TotalHours Property (System) | Microsoft Docs[^]

How to use TimeSpan in SSRS. You have to add below function:
VB
Public Function GetTotalHours(ts As TimeSpan) As Integer
	Return ts.TotalHours
End Function


How?
Add Code to a Report (SSRS) - SQL Server Reporting Services (SSRS) | Microsoft Docs[^]

Then add formula like this:
VB
=IIF(IsNothing(Fields!hours.Value), Nothing, Code.GetTotalHours(Fields!hours.Value))
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900