Split data of 1st shift and 2nd shift

Hi,
I have an SSRS report that displayed the production data. It consist of data from 1st-Shift and 2nd-Shift . My SSRS has a parameter with FromDate and Todate, Time. the default date is today's date. My requirements is to
obtain the data of 1st shift and 2nd shift on the same day and displayed into one report with separate column for 1st shift and 2ns shift. The 1st shift is always start at 6:00AM and end at 2:00PM while the 2nd shift start at 2:00PM and end at 10:00PM
Btw, This report is run every hour. THe objective is to gather how the production perform.
Any help is very much appreciated. Thanks
Sample DDL
Create table #sample
(ID nvarchar(5), DateandTime datetime, qty int)
Insert into #sample(ID, dateandtime,qty) values('XXXX','2014-05-30 00:33:18.000',1)
Insert into #sample(ID, dateandtime,qty) values('TTTT','2014-05-30 05:20:57.000',1)
Insert into #sample(ID, dateandtime,qty) values('XXXX','2014-05-29 23:09:33.000',1)
Insert into #sample(ID, dateandtime,qty) values('XXXX','2014-05-30 03:45:08.000',1)
Insert into #sample(ID, dateandtime,qty) values('TTTT','2014-05-30 04:53:55.000',1)
Insert into #sample(ID, dateandtime,qty) values('XXXX','2014-05-30 06:00:06.000',1)
Insert into #sample(ID, dateandtime,qty) values('XXXX','2014-05-30 06:15:41.000',1)
Insert into #sample(ID, dateandtime,qty) values('TTTT','2014-05-30 06:07:08.000',1)
Declare @timezoneOffset int, @D1 datetime, @D2 datetime, @Stime nvarchar(8), @ETime nvarchar(8),@FromDatetime datetime, @ToDatetime datetime
Set @timezoneOffset=8
Set @D1='2014-05-30'
Set @D2='2014-05-30'
set @Stime='06:00 AM'
set @Etime='02:00 PM'
Set @FromDatetime= @D1 +''+@Stime
Set @ToDatetime= @D2 +''+@Etime
SELECT *
FROM #sample
WHERE DATEADD(HOUR,convert(int,@timezoneOffset), dateandtime) BETWEEN (@Fromdatetime) AND (@ToDatetime)

May I ask you assistance to fix this error.
i wanted this code to have a timezoneoffset. 
Also , i would like to ask if this is acceptable  in between  6:00 and 16:00, if more than 16:00 (this is 4:00PM) this would be now under shift 2. 
case when DATEPART(hour,DateandTime)
between 6 and
16 then 1
else 2 end
as shiftID,
I tried trid this but got an error:
CASE WHEN DATEADD(HOUR,convert(int,@timezoneOffset), DateandTime)
between 6 and
16 then 1
else 2 end
as shiftID2

Similar Messages

  • Capture Excise on Purchase through 1st Level and 2nd Level

    Dear all,
    Please clear about the  Functionality to Capture Excise on Purchase through 1st Level and 2nd Level Dealer Invices in details please.
    Regards,
    Vishal

    hi,
    for dealer invoice we first do j1iex here we capture the excise duties
    then we do migo &
    again we do j1iex to post the excise invoice.

  • 1st Gen and 2nd Gen - help me?

    Ok so i'm confused here...
    The 1st gen and 2nd gen iPod touches both have the same 128mb of RAM yes...
    So why is it that the 1st gen is apparently incapable of running iOS 4?
    Yes, i understand that multi-tasking, and wallpapers(?) are too memory-intensive for the devices with such a small amount of RAM.
    But come on, surely something like folders isn't totally 100% impossible for the 1st gen??
    I know that the second gen is running @ 121Hz faster than the first but i would've thought that folders require the use of the memory over the processor?

    I make no judgements about whether these devices are iOS 4 capable or not. Nor do I offer an opinion about the policy of which devices do, and which do not, upgrade. Nevertheless, it is Apple's policy, and I unfortunately I don't think you're gonna get the answer you seek here... Sorry.
    You could try a Genius Bar or AppleCare, but only if you seek a Monty Python-style ‘Argument Clinic’...

  • Can I use the same sync cord for my 1st Gen and 2nd Gen iPod?

    I have to replace my sync cord (house fire) and I wondered if I could buy just one cord to sync both my iPods? I have a 1st Gen and a 2nd Gen.

    If they both use the same type of cord, 30-pin or lightning, then yes, you can. There is no difference to the internals of the cords, just the connectors. Just match what you need.

  • Ipod mini lcd difference between 1st gen and 2nd gen

    could someone verify for me the difference between lcd's. is the difference between the two the wideness of the lcd cable. ie: the first gen is smaller and the second gen is wider! am i correct? Thanks.

    Here are the differences between the 1st and 2nd gen mini.
    http://docs.info.apple.com/article.html?artnum=300850
    There's no difference in screen size.

  • Can't decide between the 1st gen and 2nd gen 32GB iPod Touch, please help.

    I would like to buy a 32GB iPod Touch, the problem is that i can't decide whether i should buy a 1st gen or 2nd gen.
    Obviously 2nd gen is "better" but is it worth the extra $$$?
    Best Buy has the 1st gen for $310 and the 2nd gen is $400, that's $90 difference.
    Any advice would be appreciated.

    that's $90 difference.
    Actually, it's only $80 because the 1G touch will come with the old 1.x software and it cost $10 to upgrade to 2.x software.

  • What is the difference between the 1st GEN and 2nd GEN IPOD TOUCH

    Does anyone know the changes?
    Does the 1st Gen have a a speaker?
    Message was edited by: pa-bucktail

    In addition...
    The 2nd gen will accept headphones with microphone.
    The 2nd gen has a volume control up/down button on the case.
    The 2nd gen has bluetooth capabilities which in theory will be enabled with the iPhone 3.0 software update.
    The 2nd gen can be obtained in a 32GB model as well as the 8GB and 16GB models.

  • Splitting data in one row and inserting into seperate rows into a new table

    i have a table table1 like the following
    column1     column2          column3
    a     b,cbdm,d     hj
    ba     hello          man
    i have to insert data from this table to table2 in the following format
    Column1          column2          column3
    a          b          hj
    a          cbdm          hj
    a          d          hj
    ba          hello          man
    It is like if data in column2 is seperated by comma i have to insert it into each sperate row
    I have to write a single procedure which will do the above. Please,Please help me
    I am very new to SQL

    I am absolutely agreeing with Billy.
    But I think u will be able to learn a lot if u try to understand the following code
    sql>select * from t1;
         C1 C2 C3
         a  b,cdbm,d  hj 
         ba  hello  man 
         x  aa,d,df  yy 
    sql>select * from t2;
         no rows selected
    sql>insert into t2
          select col1,col2,col3
         from (
         select t1.c1 col1,t1.c2 col4,t1.c3 col3,
         substr(t1.c2,
                  case n when 1 then 1 else instr(t1.c2,',',1,n-1)+1 end,
                       (case instr(t1.c2,',',1,n) when 0 then length(t1.c2)+1 else instr(t1.c2,',',1,n) end) -
                      (case n when 1 then 1 else instr(t1.c2,',',1,n-1)+1 end)) col2,n
           from t1,(select c1,c2,c3,
                              row_number() over(partition by c1,c2,c3 order by c1) n
                      from t1 connect by level <=
                                                   (length(t1.c2)-length(replace(t1.c2,',','')))) t2
           where t1.c1 = t2.c1)
         where not(n != 1 and col4=col2);
    sql>select * from t2;
          C1 C2 C3
          a  b  hj 
          a  cdbm  hj 
          a  d  hj 
          ba  hello  man 
          x  aa  yy 
          x  d  yy 
          x  df  yy                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • I want to display data from 1st form to 2nd form...

    Hi
    I'm having 2 Forms.In the 1st form i'm having Master & Detail Blocks.
    By clicking button i'm trying to call another form.
    In that form i what to see the Master Block Data should be displayed on the form.
    So wht is the type of Canvas can i use or is there any other alternative way for this issue.
    Try to help me in this
    Regards
    Siva

    Go through this
    1 form data display 2 form

  • Touch 1st gen and 2nd gen headphone jack question

    Alright so my headphone jack crapped the bed and i was looking into just buying the jack and repairing it myself. Now when i look on the internet for a headphone jack, the only things i see sold are 2nd gen hp-jacks. now would this work in my first generation ipod touch? they look identical. I just want to confirm before i buy it.

    the only difference between the the two jacks is the 2G has three contacts compared to just two on the 1g. I would rather replace the 1G's headphone jack with the 2G. Two contacts are for stereo left and right. The three contacts for the 2G is for stereo left and right plus mic. Then you can use your 1g to make wifi calls with Skype. I plan on doing this to my 1g as my 2G already has it from the factory which is one of the changes of the 2G from the 1G. Let me know how it goes.

  • Can I switch calendars (Ex. "night shift" to "day shift" cal) with a repeating event, but ONLY for that one event??  It asks "for all events or only this event" if i change the time.  But it changes ALL events when i try and switch calendars.  Any help??

    I have 2 calendars set up for my work schedule, a "night shift" and "day shift" calendar.  I've set up repeating events fro Fri/Sat/Sun 3-11pm "night shifts" and Mon/Tues 7am-3pm "day shifts".  But lets say for example that I swap shifts and instead of working nights on Saturday like I normally would, I am now working days.  I want to change that in my calendar.  When I go to change the event, if i change the TIME it asks if i want to change all event or ONLY this event.  no problem....just this single event.  but when i go to change the event from the "night shift" calendar to the "day shift" calendar, it changes ALL the repeating events, and not just that one single event.   can anyone help with this???  am i doing something wrong?  is there a way to do this or not with the new iCal program???  i used to do this and never had any problems.    Thank you!

    You need to follow iPhoto terms since we only know what you tell us
    what are you calling folders - in iPhoto folders can not hold photos - albums hold photos and folders hold albums or other folders
    The basic default view of photo is by event (iPhoto '08 and later)
    Exactly what you you trying to do?
    LN

  • HT202157 What is the difference between the 1st and 2nd generation Apple TV?

    What is the main difference between the 1st and 2nd generation Apple TV's? I just got the 1st generation and was wondering if I should send back for the 2nd gen?

    There is one other difference. The ATV3 uses a new processor with a better graphic processing unit.  If you only had the ATV2 for less than 14 day. Why not upgrade. 1080p video will be a little sharper, but in reality most people won't notice any real difference. It's likely that Apple will stop supporting the ATV 1st gen and 2nd gen in couple of years. Apple as a company usually only supports hardware 5-6yrs max! 

  • When I click the launchpad, (I have icons on 2 pages) how do I return to the 1st set when the system seems to automatically shift to 2nd page?

    When I click the launchpad, (I have icons on 2 pages) how do I return to the 1st set after the system seems to automatically shift to 2nd page?.
    I'm not aware of anything I might have done, but it's annoying to want to use an icon on the 1st page, only to see all the icons on page 1 shift rapidly to the left
    and I can't find a way to shift back to page 1.
    Is there a way of getting all my Launchpad icons onto 1 page by adjusting their size?

    Thanks for that. I think the 2 little white dots were hidden by the white frame round the desktop picture on my screen
    As you can see from the pic, there is a broad white frame around the image.

  • How do i access my installer disc on a 2011 macbook pro as they are virtual now, i have tried to use command r and hold shift on start up

    I have, a 2011 macbook pro with osx lion, last year  it died, by doing the not getting past the logo and startup gear, i tried doing the data screen repair where u type some code and try and repair, that didnt work so i took it to genius bar and it wasnt in warrenty and they were gonna charge me but as was only 3 weeks over the warrenty period, so they did for free, and the harddrive they installed had a 90 day warrenty and that is ova now, and my mac has now done the same thing again and this time i think was a power interruption at some point and now has a fault, another thing that crossed my mind is that yes this has done this but could they have (to save money and not right offf a new one) given me my same harddrive back and jus wiped it now 5 months down the track its broken again?
    The laptop isnt even 18 months old and has broken down twice, my old macbook had 4 5 years not a hiccup.
    In conclusion i need to get photoes off it and cant seem to activate safe mode, or do i know how to access the startup disk that the guy did at genius last time, or get to the data screeen that allowed me to attempt to repair the drive. Can someone help me please, i have tried command r and holding shift, meither have worked.

    It's hard to know whether your hard drive has actually failed or if your system has just gotten badly corrupt. If the former, unfortunately, there may be no way to get any data off the drive at this point. If there aren't any backups of that data, it will be gone forever, unless perhaps a high-priced (ie, in the thousand dollar range) data recovery service has some luck with it.
    If the system and/or hard drive are badly corrupt, the same may be true. Some or all of that data may be irrevocably corrupt by now. However, there are some ways that you can attempt to recover from this situation without paying such huge fees. First, if you have access to another Mac, and both have Firewire ports, you can connect the two using Firewire target disk mode. This will mount the damaged drive as if it were an external hard drive on the second Mac, and could allow you to copy some data from the drive.
    Another possibility would be to buy an external hard drive, install Mac OS X on it and boot the machine from that, then copy any data from there that you can.
    In both of these cases, it may be helpful to scan the damaged drive for recoverable files using something like Data Rescue.
    There are also some possible ways to repair the drive if you can't do either of those things, but any repairs at this point could potentially destroy data. I only recommend this as a last resort. Still, if all other options have failed, try repairing the drive using DiskWarrior. This can fix problems that Disk Utility (and fsck, the command-line tool that it sounds like you may have used) cannot. It is possible that DiskWarrior will be able to get the drive back in working order long enough to get the data recovered, though of course it's also possible the process will be destructive.
    If none of the above work, you'll have to seek professional help.

  • Remove 1st & 2nd lines in 1st file, and 1st line in 2nd file. I want the headers to be the first line after the script runs!

    I have two files that look like this (Notepad++):
    In the first file, which has a date as a name and always ends in 'COV', I want to remove the 1st & 2nd lines.  All lines end in LF (LineFeed).  In the 2nd file, which has a date as a name and always ends in 'RSK', I want to remove the 1st line. 
    Basically I want only the headers.  I'm working with the code below.  I've tried several different iterations of
    reader.ReadLine().Skip(1);
    reader.ReadLine().Skip(2);
    reader.ReadLine().Skip(3);
    It never really gives me what I want, so I can't tell what's going on here.  I guess I'm missing something simple, but I don't know what.  Any ideas, anyone?
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.Diagnostics;
    namespace ConsoleApplication1
    class Program
    static void Main(string[] args)
    string sourceDirectory = @"C:\Users\rshuell\Desktop\Downloads\Files";
    try
    var txtFiles = Directory.EnumerateFiles(sourceDirectory);
    foreach (string currentFile in txtFiles)
    if (currentFile.Contains("COV"))
    var items1 = new LinkedList<string>();
    using (var reader = new StreamReader(currentFile))
    reader.ReadLine().Skip(2); // skip 2lines
    string line;
    while ((line = reader.ReadLine()) != null)
    items1.AddLast(line.Replace("\"", ""));
    File.WriteAllLines(currentFile, items1);
    else
    var items2 = new LinkedList<string>();
    using (var reader = new StreamReader(currentFile))
    reader.ReadLine().Skip(1); // skip one line
    string line;
    while ((line = reader.ReadLine()) != null)
    items2.AddLast(line.Replace("\"", ""));
    File.WriteAllLines(currentFile, items2);
    catch (Exception ex)
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    Call the ReadLine() twice if you want to skip the first two lines. Each call results in a single line being read:
    static void Main(string[] args)
    string sourceDirectory = @"C:\Users\rshuell\Desktop\Downloads\Files";
    try
    var txtFiles = Directory.EnumerateFiles(sourceDirectory);
    foreach (string currentFile in txtFiles)
    if (currentFile.Contains("COV"))
    var items1 = new LinkedList<string>();
    using (var reader = new StreamReader(currentFile))
    reader.ReadLine(); //read line 1
    reader.ReadLine(); //read line 2
    string line;
    while ((line = reader.ReadLine()) != null)
    items1.AddLast(line.Replace("\"", ""));
    File.WriteAllLines(currentFile, items1);
    else
    var items2 = new LinkedList<string>();
    using (var reader = new StreamReader(currentFile))
    reader.ReadLine(); // skip one line
    string line;
    while ((line = reader.ReadLine()) != null)
    items2.AddLast(line.Replace("\"", ""));
    File.WriteAllLines(currentFile, items2);
    catch (Exception ex)
    Calling the Skip method on the already read string returned by the ReadLine() method won't help you at all here. By the time you call the Skip method the line has already been read from the file. You must call the ReadLine() method for a new line being read.
    Hope that helps.
    Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

Maybe you are looking for

  • Process runs in the background and shown as an icon next the clock (how to?

    Hi guys, I have a program that runs in the background (a daemon). It refers to a database and make some calculations. If it's not activated, the database will lack some critical information. For this propose, I eliminated the closing option from the

  • DOC BUG: Oracle Application Express Application Builder User's Guide 4.1

    Oracle® Application Express Application Builder User's Guide Release 4.1 Part Number E21674-03 +§ HTML Header and Body Attribute+, Table 8-4 has: > Attribute: Page HTML Body Attribute Description: Enter text or HTML you want to appear before the page

  • 3 way match on balance sheet accounts

    Hello, Our company has decided to get away from direct FI Invoices. We want to raise POs for everything we can. We have got some annual maintenance contracts and insurance premiums for which we receive one invoice for full year. These invoices are po

  • Process.waitfor seems to wait indefinately

    Hello I'm running the folowing code from Java: Runtime run = Runtime.getRuntime(); Process proc = run.exec(cmd); proc.waitFor(); I've used this piece of code before in other programs and never had any problems with it. Now, however, the program hangs

  • Cvhelper.exe has stopped working

    Prior to updating Mozilla to Mozilla 4 the download helper would convert downloaded videos to a chosen extension without problems. However in following with the update to Mozilla 4 the download helper is unable to convert videos. Message reads: "cvhe