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.
Author |
Topic |
jhaney
Starting Member
33 Posts |
Posted - 2011-05-06 : 11:10:09
|
Hello all,I have the following in a select statement thet I am using in SSRS 2005SELECT COMPANY.DEPARTMENT, --ORDER SHIP TIME convert (varchar,(CAST(COMPANY.OrderShipped as datetime))- (CAST(COMPANY.OrderPlaced as datetime)), 108) as Order_ship_timeFrom COMPANYWhere COMPANY.DEPARTMENT = 'ORDER' Group By COMPANY.DEPARTMENTThis works great and gives me the followingDepartment Order_ship_TimeORDER 01:00:00ORDER 00:45:00ORDER 01:15:00ORDER 01:30:00Now I am trying to right a report that will show me the percentage of orders that take longer than 01:00:00 to shipBut when I try the following expression=sum(iif(Fields!Report_turnaround_time.Value > 01:00:00, 1, 0)) \ (sum(Fields!Report_turnaround_time.Value)) It doesn't like the 01:00:00 it puts a red squiggle under the first :Thanks in advance for any help with thisJoshua |
|
Bazalddo
Starting Member
22 Posts |
Posted - 2011-05-24 : 11:53:26
|
You would probably be better off writing it within the SQLtry thisSELECT ((CASE WHEN Order_ship_time > 01:00:00 THEN COUNT(1) END) / COUNT(1)) AS OrdersPlacedAfter1PctFROM ......WHERE ......Shahbaz AhdiApps DeveloperODEON/UCI Cinema |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-05-24 : 12:47:05
|
If you are trying to compare times (i.e., turnaround_time is a datetime or time column) you will need to do something like this:TimeValue(Fields!Report_turnaround_time.Value) > TimeValue("01:00:00") If you are trying to count the number of hours then instead of the TimeValue function, use the Hour function. Expression editor in SSRS lists all the functions avaialable to you.Similary, in the denominator, if you are trying to add up the hours, then use the Hour function. You cannot sum up time. |
|
|
|
|
|