srodgers45
asked on
Convert date time to show letters for shifts in SSRS report builder 3.0
I am trying to convert dates to show as a shift letter. I.E. based on a 48 hour rotation beginning at 08:00 (am) for each day it would show the corresponding shift based on the date/time.
1-2-2011 before 08:00 = "A"
1-3-2011 before 08:00 = "A"
1-4-2011 before 08:00 = "B"
1-5-2011 before 08:00 = "B"
1-6-2011 before 08:00 = "B"
1-7-2011 before 08:00 = "C"
1-8-2011 before 08:00 = "C"
then back to
1-9-2011 before 08:00 = "A"
And repeats from there.
The screen shot I have shows how I have it set up for a formula in Crystal, it works great. I am new to SSRS and not sure how to reproduce it for those reports? Any help is appreciated.
1-2-2011 before 08:00 = "A"
1-3-2011 before 08:00 = "A"
1-4-2011 before 08:00 = "B"
1-5-2011 before 08:00 = "B"
1-6-2011 before 08:00 = "B"
1-7-2011 before 08:00 = "C"
1-8-2011 before 08:00 = "C"
then back to
1-9-2011 before 08:00 = "A"
And repeats from there.
The screen shot I have shows how I have it set up for a formula in Crystal, it works great. I am new to SSRS and not sure how to reproduce it for those reports? Any help is appreciated.
No. If you are using 2008 just right click on the report design area and pick Code tab.
ASKER
I think i almost there - i believe I need to add a date value in the expression, correct? Forgive my ignorance
Shift-ID-Formula-3.bmp
Shift-ID-Formula-3.bmp
you need two different values in the expression, not both CREATED
ASKER
I think I am still missing something - doesn't there need to be a date for the shift starting point in the expression field? It should start over after 6 days "AABBCCAABBCC............F OREVER"
I changed the expression to 2 different values:
=Code.ShiftChange(Fields!T date.Value , Fields!CREATED.Value) - ---- Should there be a shift start date value set in this expression? It would be the Tdate field if so.The screen shot example at the top from crystal formula has a static value for the shift start.
And should the code have a table value 'CREATED' to use for the shft start and stop time as well?
Sorry to be a pain, just not familiar with this application, I am going to be sooner than later. I know I am close to getting it right. Thank You for the help so far.
what I am trying to show in the screen shot is:
The 4th should be C prior to 0800 on the 5th,
Then
The 5th and 6th after 0800 are A,
The 7th and 8th after 0800 are B,
The 9th and 10th after 0800 are C,
Then it starts over again
This is the report I am showing results for:
I changed the expression to 2 different values:
=Code.ShiftChange(Fields!T
And should the code have a table value 'CREATED' to use for the shft start and stop time as well?
Sorry to be a pain, just not familiar with this application, I am going to be sooner than later. I know I am close to getting it right. Thank You for the help so far.
what I am trying to show in the screen shot is:
The 4th should be C prior to 0800 on the 5th,
Then
The 5th and 6th after 0800 are A,
The 7th and 8th after 0800 are B,
The 9th and 10th after 0800 are C,
Then it starts over again
This is the report I am showing results for:
You need to get me a start point.
Like the shift start is 1/4/2011 and the created date is 1/4/2011
You only show me the fininshed date.
Like the shift start is 1/4/2011 and the created date is 1/4/2011
You only show me the fininshed date.
In other words I need to see what you want going in and what the real answer is suppose to be outing out.
ASKER
The start date would be 2010-12-31 would be the first A shift date, the created date has the date and time for which the shift would correspond to. So on 12-31-2010 @ 0800 A shift starts for 48 hours. What I show on the report is any created date within that 48 hours has the corresponding shift. On 1-2-2011 at 0800 B shift starts, and so on.Does that make sense? The date and setup on the screen shot at the top of the page for the crystal formula is accurate for the current report I have in crystal. I just cannot use it for what I need now. I am trying to basically duplicate that formula for SSRS report.
Thanks
Thanks
Ok the code is showing the same now as the very top code of
'1-2-2011 before 08:00 = "A"
'1-3-2011 before 08:00 = "A"
'1-4-2011 before 08:00 = "B"
'1-5-2011 before 08:00 = "B"
'1-6-2011 before 08:00 = "B"
'1-7-2011 before 08:00 = "C"
'1-8-2011 before 08:00 = "C"
'then back to
'1-9-2011 before 08:00 = "A"
'And repeats from there.
Let me know if that still does not work.
'1-2-2011 before 08:00 = "A"
'1-3-2011 before 08:00 = "A"
'1-4-2011 before 08:00 = "B"
'1-5-2011 before 08:00 = "B"
'1-6-2011 before 08:00 = "B"
'1-7-2011 before 08:00 = "C"
'1-8-2011 before 08:00 = "C"
'then back to
'1-9-2011 before 08:00 = "A"
'And repeats from there.
Let me know if that still does not work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Still the same result?
Forgive me, I must be explaining it wrong? I dont understand how the code knows what to use for a start date for the first A shift date? is it based on this expression formula? Should there be a date defined for the value? I am trying to understand it
=Code.ShiftChange(Fields!T date.Value , Fields!CREATED.Value)
12-31-2010 @ 0800 is the "First A Shift day" (for the next 48 hours it is A shift) based on Fire Department Shifts, I am reporting on incomplete reports for any incident generated from then until:
1-1-2011 before 08:00 = "A"
Then
'1-2-2011 before 08:00 = "A"
Then
'1-3-2011 before 08:00 = "B"
Then
'1-4-2011 before 08:00 = "B"
Then
'1-5-2011 before 08:00 = "B"
Then
'1-6-2011 before 08:00 = "C"
Then
'1-7-2011 before 08:00 = "C"
'And then repeats from there.
In this crystal formula it has a start date for A shift of 1-5-2010
This is what the report from crystal looks like, The colored box shows the shift working on the date shown on the left, which is the from "CREATED" date/time table
Forgive me, I must be explaining it wrong? I dont understand how the code knows what to use for a start date for the first A shift date? is it based on this expression formula? Should there be a date defined for the value? I am trying to understand it
=Code.ShiftChange(Fields!T
12-31-2010 @ 0800 is the "First A Shift day" (for the next 48 hours it is A shift) based on Fire Department Shifts, I am reporting on incomplete reports for any incident generated from then until:
1-1-2011 before 08:00 = "A"
Then
'1-2-2011 before 08:00 = "A"
Then
'1-3-2011 before 08:00 = "B"
Then
'1-4-2011 before 08:00 = "B"
Then
'1-5-2011 before 08:00 = "B"
Then
'1-6-2011 before 08:00 = "C"
Then
'1-7-2011 before 08:00 = "C"
'And then repeats from there.
In this crystal formula it has a start date for A shift of 1-5-2010
This is what the report from crystal looks like, The colored box shows the shift working on the date shown on the left, which is the from "CREATED" date/time table
the firstshift date was the 12-31-2010
ASKER
Correct, first A shift is 12-31-2010 Thanks
ASKER
Did you give up on me? I know I have. Sorry for any confusion
ASKER
Thanks, I think I wore you out on this. I reposted hopefully with a better expalnation of what I am trying to do.
You will need to test it. I think I got it pretty close.
Then have this code in your cell or textbox
=Code.ShiftChange(Fields!M
Open in new window