July 27, 2011 at 11:39 am
I am working a report where I need to group by shift (1st,2nd,3rd). The text below is a function used in a Crystal Report I have that is used to build the shift. In the function @HOUR is another function that uses an aggregate function to get the hour od the day for each record. This is written in Crystal syntax.
StringVar DS;
if {@HOUR} in [7.00,8.00,9.00,10.00,11.00,12.00,13.00,14.00] then
DS:="First Shift"
else
if {@HOUR} in [15.00,16.00,17.00,18.00,19.00,20.00,21.00,22.00] then
DS:="Second Shift"
else
DS:="Third Shift"
What would be the best way to accomplish this in report designer. If you can point me to an example that would be great.
July 27, 2011 at 12:32 pm
You didn't give us much to go on with regard to the data you have to work with, but I would be inclined to do this in the dataset. Something like
CASE WHEN @Hour BETWEEN 7:00 AND 14:00 THEN 'First Shift"
WHEN @Hour BETWEEN 15:00 AND 22:00 THEN 'Second Shift"
ELSE 'Third Shift'
END AS Shift
July 27, 2011 at 2:04 pm
Case worked. Here's the code.
select shift = case
when datepart (hh,calltime) >= 7 and datepart (hh,calltime) < 15 then 'First'
when datepart (hh,calltime) >= 15 and datepart (hh,calltime) < 23 then 'Second'
else 'Third'
end,
calltime
from inmain
Thanks!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply