January 11, 2012 at 3:30 am
Hi
I have a requirement where a field in SSRS report should be shown as (Days, Hours)
Ie. If it is 50hours it should be shown as 2days 2hours.
Any help is appreciated.
January 11, 2012 at 5:31 am
In SQL, something like this -
BEGIN TRAN
--Sample data
CREATE TABLE timing (timing INT)
INSERT INTO timing
SELECT *
FROM (VALUES(50),(24),(20),(1),(16),(360),(14000))a(timing)
SELECT timing,
CASE WHEN (timing / 24) = 1
THEN CONVERT(VARCHAR(6),(timing / 24)) + 'day '
WHEN (timing / 24) > 1
THEN CONVERT(VARCHAR(6),(timing / 24)) + 'days '
ELSE '' END +
CASE WHEN (timing - ((timing / 24) * 24)) = 1
THEN CONVERT(VARCHAR(2),timing - ((timing / 24) * 24)) + 'hour'
WHEN (timing - ((timing / 24) * 24)) > 1
THEN CONVERT(VARCHAR(2),timing - ((timing / 24) * 24)) + 'hours'
ELSE '' END
FROM timing
ROLLBACK
The syntax for SSRS is a little different, but the principle is the same.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply