Get datetime delta gaps

Finding datetime gaps:
we have a table with cars working from to dates:
rec    car    DateFrom        DateTo
1    11    2008-10-28 00:00:00    2008-11-05 23:59:59
2    11    2008-11-06 00:00:00    2008-11-08 23:00:00
3    11    2008-11-09 00:00:00    2008-11-05 23:59:59
4    22    2008-10-28 00:00:00    2008-10-29 20:00:00
5    22    2008-10-31 00:00:00    2008-11-05 23:59:59
result I'm lookin for is finding dates and delta time a car is not working:
car    gapFrom         gapTo            gapDelta[h]
11    2008-11-08 23:00:00    2008-11-09 00:00:00    1     (in hours)
22    2008-10-29 20:00:00    2008-10-31 00:00:00    28    

Hi b_blase,
Please see the below code to retrieve datetime delta gaps.
CREATE TABLE yourTable
rec INT,
car INT,
dateFrom DATETIME,
dateTo DATETIME
INSERT INTO yourTable VALUES(1,11,'2008-10-28 00:00:00','2008-11-06 00:00:00'),
(2,11,'2008-11-06 00:00:00','2008-11-08 23:00:00'),
(3,11,'2008-11-09 00:00:00','2008-11-10 00:00:00'),
(4,11,'2008-11-10 11:37:00','2008-11-11 00:00:00'),
(5,22,'2008-10-28 00:00:00','2008-10-29 20:00:00'),
(6,22,'2008-10-31 00:00:00','2008-11-05 00:00:00'),
(7,22,'2008-11-07 00:00:00','2008-11-11 00:00:00');
;WITH CTE AS
SELECT *,ROW_NUMBER() OVER(PARTITION BY car ORDER BY dateFrom) AS rn FROM yourTable
CTE2 AS
SELECT c1.car car,c2.dateTo gapFrom, c1.dateFrom gapTo
FROM CTE c1 LEFT JOIN CTE c2
ON c1.rn=c2.rn+1 AND c1.car=c2.car
WHERE c1.dateFrom <> c2.dateTo
SELECT *,CAST(ROUND(DATEDIFF(MINUTE,gapFrom,gapTo)/60.0,2) AS NUMERIC(20,1)) gapDelta FROM CTE2 ORDER BY car,gapTo;
DROP TABLE yourTable;
I just made a little modification on the dateTo column so that the
dateTo equaling to the dateFrom of next record can be identified as no gap. If you still prefer the dateTo valuing like ‘2008-11-06 23:59:59‘ as it was, you just modify the WHERE clause as below.
WHERE DATEDIFF(MINUTE,c2.dateTo,c1.dateFrom) <> 1
If you have any question, feel free to let me know.
Best regards,
Eric Zhang

Similar Messages

  • We are trying to delete picture but it leaves a gap. How do you get rid of gap?

    How do you get rid of gap after deleting picture

    njmediaproductions
    Information, please.
    What version of Premiere Elements are you using and on what computer operating system is it running?
    What are you clicking on..."Delete" or "Delete and Close Gap"?
    "Delete and Close Gap" may not work if there is content directly above or below the place where you want to delete and close gap.
    In that case, you use the mouse cursor to close the gap. Also please read some situations where Delete and Close Gap fails.
    http://www.atr935.blogspot.com/2014/02/pe-delete-and-close-gap-failures.html
    Please give us more details of the Timeline content involved in your Delete and Close Gap matter, and we will customize a how to
    answer for you if you have not found your answer in the above.
    Looking forward to your follow up.
    Thanks.
    ATR

  • Delta Gap in LO

    Hi Experts,
                          Can anybody tell me about what is Delta Gap in LO?
    and also two more doubts, 1. Where to maintain currency conversations?
    2. Where to create currency types?
    Thanx in Advance,
    Balaji Reddy

    Hi dear,
    better to open different threads when subjects are so different...
    Anyway,
    about currency conversion, look here:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/ec/076f3b6c980c3be10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/80/1a6813e07211d2acb80000e829fbfe/content.htm
    About "delta gap" I don't know what you exactly want to mean...could you please give us some more detail ?
    Hope it helps!
    Bye,
    Roberto

  • How should i get the delta data for those new object's previous delta data?

    Hallo all,
    i have 2lis_11_vahdr and i am using a standard and loading delta! now i have appended some new fields in the datasource then in infosource then in ods and infocube..! now how should i get the delta data for those new object's previous delta data???
    Jimmy

    Hi,
    After appending new fields in the datasoure.It is not possible to delta load, u should have to load everything
    Thanks,
    Shreya

  • Safari 6 won't let me get into the gap website

    For the past few weeks I have had no luck putting the gap url into my safari bar and getting into the gap website including all of their partners. I contacted gap thinking it was a glitch on their end since I could get into Any other website with no problem. When I try to get onto the website it pops up that "I'm sorry but our site is temporarily unavailable"; however, when I click on the gap link from google it takes me to the website. It is only when I try to type the url in my bar that it won't link me over and I get that weird message. The gap got back to me and told me to get rid of my "cache" (which I cannot seem to find according to their instructions) and cookies which I did do and it still is not allowing me in. Any help is greatly appreciated.

    Select Safari ▹ Preferences ▹ Extensions from the Safari menu bar. If any extensions are installed, disable them and test.

  • Trouble getting rid of gap under navigation (SS Provided)

    I am creating a page from scratch and I used the Insert
    navigation option. Now there is a gap under my nav buttons. As you
    can see, In dreamweaver it looks fine. Exactly how I want it to be.
    But when I hit F12 to preview in browser I get this lil gap under
    my nav that throws off the look of the site. Anyone know how to
    remove it?
    Here is it looking correctly in dreamweaver:
    http://www.geocities.com/coreysnyder042/ss4.jpg
    Here is it looking wrong in web browser:
    http://www.geocities.com/coreysnyder042/ss3.jpg

    All of my buttons are the exact same height. It is not
    larger. I just put a grey area above the other buttons. This
    allowed me to have the page the user is browsing to have a "lifted"
    or "selected" feature.
    I am not sure what you were trying to say in your message
    BTW. There is no refresh button in my dreamweaver properties panel
    so I'm not sure what your talking about.

  • How to get DATETIME value in a page?

    Hi,
    I have two pages.
    In page1, I have a table that contain MessageStyleText item(AuditTime) and the attribute data type is DATETIME .
    I want to pass AuditTime value from page1 to page2.
    I am passing the AuditTime value from page1 to page2 using Destination URI.
    The AuditTime value is 2008-11-11 12:45:31.0
    How to get the AuditTime in page2 so that I can get the exact value '2008-11-11 12:45:31.0' ?
    Please help.
    Thanks & Regards,
    Sagarika

    Hi
    I am passing the value using the following destination URI,
    OA.jsp?page=/uttara/oracle/apps/uttaraimc/audit/webui/Page2&auditTime={@AuditTime}&retainAM=Y
    In the database the AuditTime value is like '2008-11-11 12:45:31.0'
    Normally we are using pageContext.getParameter("auditTime"); to get the value which are passed in destination URI.
    Here if I'll use pageContext.getParameter("auditTime"); I am not getting the correct value.
    How to get the exact value?
    Thanks & Regards,
    Sagarika

  • How to get the rows gap in the application file...?

    Hi All,
    Im working with Application server and I have a query like after transferring / printing 100 rows in the App server, I need 2 to 3 rows gap and then remaining will print.
    How to get the gap in the application file.
    Pls let me know.
    Puppy.

    Hi,
    when you are transfering the data to file
    loop at itab in wa_itab.
    counter  = count + 1.
    transfer wa_itab to fiel.
    if counter = 100
        clear wa_itab.
        transfer wa_itab to fiel.
        transfer wa_itab to fiel.
        transfer wa_itab to fiel.
       clear counter.
    endif.
    endloop.
    regards,
    Munibbau.K

  • Problem in getting Generic Delta records to BW

    Hi BW Gurus,
    I have got one issues with which I have been struggling a lot for several days . i.e
    I am extracting data from R/3 using Generic Extractor (View) from CATSCO and CATSDB. At the time of delta, I tried using Personal  No with Time Stamp giving Upper limit as 1800 seconds. I executed Infopackage in BW immediately. But it didn't work out. So plz guide me how I can get Delta Records to BW. Or should I do any  necessary factors apart from these in Generic Delta Screen (RSO2).
    It is very urgent.
    I will be thankful for solving this issue.

    Hey I am "Intros" again,,
    I am sorry man for giving the wrong T-code mistakenly in my last reply..
    To solve the proble...the whole process is same what I told u before..
    But... you got to go to T-Code :  BD87   , then execute the IDocs manually to bring them in to BW
    identify your IDocs which are missing in Monitor screen, then goto BD87 and select those IDocs and click execute... )you can search the IDoc's based on selection conditions)
    I hope this will help u...
    cheers man..
    ---Intros

  • Can't get rid of gap around edge

    Hi there,
    I'm struggling to get rid of the gap around the edge of the website I've just started building.  I've got the margins set to 0 for the top, and the divs are 100% width.  Does anybody have any ideas?  I've attached a picture to demonstrate and also please see the code pasted in below, in case that's useful.
    Thanks,
    Mark
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    #header {
        background-image: url(images/header_background.jpg);
        background-repeat: repeat-x;
        height: 230px;
        width: 100%;
        margin-top: 0px;
    #navbar {
        background-image: url(images/navbar_background.jpg);
        background-repeat: repeat-x;
        height: 34px;
    #container_navbar {
        height: 34px;
        width: 852px;
        margin-right: auto;
        margin-left: auto;
    #main_text {
        background-image: url(images/maintext_background.jpg);
        background-repeat: repeat-x;
        height: 536px;
        width: 100%;
    #container_header {
        background-image: url(images/header_image.jpg);
        background-repeat: no-repeat;
        margin-top: 0px;
        margin-right: auto;
        margin-bottom: 0px;
        margin-left: auto;
        height: 230px;
        width: 852px;
    #container_maintext {
        height: 536px;
        width: 852px;
        margin-right: auto;
        margin-left: auto;
    #footer {
        background-image: url(images/footer_background.jpg);
        background-repeat: repeat-x;
        height: 200px;
        width: 100%;
    #container_footer {
        height: 200px;
        width: 852px;
        margin-right: auto;
        margin-left: auto;
    -->
    </style>
    </head>
    <body>
    <!--Header-->
    <div id="header">
      <div id="container_header"></div> 
    </div>
    <!--Navbar-->
    <div id="navbar">
      <div id="container_navbar">SPRY MENU GOES HERE</div>
    </div>
    <!--Main Text-->
    <div id="main_text">
      <div id="container_maintext">MAIN CONTENT GOES HERE</div></div>
    </div>
    <!--Footer-->
    <div id="footer">
      <div id="container_footer">FOOTER CONTENT GOES HERE</div>
    </div>
    </body>
    </html>

    Add the below to your css styles:
    body {
    margin: 0;
    padding: 0;

  • Get datetime in 1st row of another column

    Hi Everyone,
    Please anyone help me...
    Below is the query and output.
    Query:
    SELECT
      WMUMF.BIZDOCTYPEDEF.TYPENAME,
      Table__52.BD_PARTNERORDERNUMBER,
      Table__67.BD_TRACKINGNUMBER,
      WMUMF.BIZDOCATTRIBUTE.STRINGVALUE,
      TO_DATE(TO_CHAR(WMUMF.BIZDOC.DOCTIMESTAMP,'MM/DD/YYYY HH24:MI:SS'),'MM/DD/YYYY HH24:MI:SS')
    FROM
      WMUMF.PARTNER  SENDER,
      WMUMF.PARTNER  RECEIVER,
      WMUMF.BIZDOCTYPEDEF,
      WMUMF.BIZDOC,
      SELECT
          WMUMF.BIZDOCARRAYATTRIBUTE.DOCID,
          WMUMF.BIZDOCARRAYATTRIBUTE.STRINGVALUE BD_PartnerOrderNumber
          FROM
          WMUMF.BIZDOCATTRIBUTEDEF  BIZDOCATTRIBUTEDEF_A1,
          WMUMF.BIZDOCARRAYATTRIBUTE
          WHERE
          WMUMF.BIZDOCARRAYATTRIBUTE.ATTRIBUTEID=BIZDOCATTRIBUTEDEF_A1.ATTRIBUTEID AND
          Bizdocattributedef_A1.Attributename  In  ( 'BD_PartnerOrderNumber'  )
      )  Table__52,
      SELECT
    WMUMF.BIZDOCARRAYATTRIBUTE.DOCID,
    WMUMF.BIZDOCARRAYATTRIBUTE.STRINGVALUE BD_TrackingNumber
    FROM
    WMUMF.BIZDOCATTRIBUTEDEF BIZDOCATTRIBUTEDEF_A1,
    WMUMF.BIZDOCARRAYATTRIBUTE
    WHERE
    WMUMF.BIZDOCARRAYATTRIBUTE.ATTRIBUTEID=BIZDOCATTRIBUTEDEF_A1.ATTRIBUTEID AND
    Bizdocattributedef_A1.Attributename In ( 'BD_TrackingNumber' )
      )  Table__67,
      WMUMF.BIZDOCATTRIBUTEDEF,
      SELECT
          WMUMF.BIZDOCARRAYATTRIBUTE.DOCID,
          WMUMF.BIZDOCARRAYATTRIBUTE.STRINGVALUE BD_SiteID
          FROM
          WMUMF.BIZDOCATTRIBUTEDEF  BIZDOCATTRIBUTEDEF_A1,
          WMUMF.BIZDOCARRAYATTRIBUTE
          WHERE
          WMUMF.BIZDOCARRAYATTRIBUTE.ATTRIBUTEID=BIZDOCATTRIBUTEDEF_A1.ATTRIBUTEID AND
          Bizdocattributedef_A1.Attributename  In  ( 'BD_SiteID'  )
      )  Table__44
    WHERE
      ( WMUMF.BIZDOC.DOCTYPEID=WMUMF.BIZDOCTYPEDEF.TYPEID  )
      AND  ( WMUMF.BIZDOC.RECEIVERID=RECEIVER.PARTNERID  )
      AND  ( SENDER.PARTNERID=WMUMF.BIZDOC.SENDERID  )
      AND  ( WMUMF.BIZDOC.DOCID=WMUMF.BIZDOCATTRIBUTE.DOCID  )
      AND  ( WMUMF.BIZDOCATTRIBUTEDEF.ATTRIBUTEID=WMUMF.BIZDOCATTRIBUTE.ATTRIBUTEID  )
      AND  ( Table__44.DOCID(+)=WMUMF.BIZDOC.DOCID  )
      AND  ( WMUMF.BIZDOC.DOCID=Table__46.DOCID(+)  )
      AND  ( WMUMF.BIZDOC.DOCID=Table__52.DOCID(+)  )
      AND  ( WMUMF.BIZDOC.DOCID=Table__67.DOCID(+)  )
      AND
       WMUMF.BIZDOCTYPEDEF.TYPENAME  IN  ( 'doc_Xml_HoldReleaseNotification_CustomXML_Cisco','doc_Xml_PIP_3A9CancellationRequest_V_11_01'  )
       AND
       SENDER.CORPORATIONNAME  =  'CISCO LSS (E2Open)'
       AND
       RECEIVER.CORPORATIONNAME  =  'FLEXTRONICS'
       AND
       WMUMF.BIZDOCATTRIBUTEDEF.ATTRIBUTENAME  =  'ApplicationMessageType'
       AND
       WMUMF.BIZDOCATTRIBUTE.STRINGVALUE  IN  ( 'H','R','3A9V11.01.00'  )
       AND
       Table__44.BD_SITEID  =  '027'
      AND
       WMUMF.BIZDOC.DOCTIMESTAMP >= TO_DATE('06/15/2013','MM/DD/YYYY')
       AND WMUMF.BIZDOC.DOCTIMESTAMP <= SYSDATE+1
    Output:
    PartnerOrderNumber
    DateTime
    StringValue
    Tracking Number
    Document
    PO1
    1 am
    H
    123
    DOC
    PO1
    2 am
    H
    246
    DOC
    PO1
    3 am
    R
    125
    DOC
    PO1
    4 am
    H
    678
    DOC
    PO2
    5 am
    H
    890
    DOC
    PO2
    6 am
    R
    098
    DOC
    PO2
    7 am
    H
    001
    DOC
    PO2
    8 am
    R
    870
    DOC
    PO3
    9 am
    H
    008
    DOC
    PO3
    10 am
    H
    065
    DOC
    PO3
    11 am
    R
    593
    DOC
    PO3
    12 pm
    H
    636
    DOC
    PO3
    1 pm
    H
    978
    DOC
    PO3
    2 pm
    R
    675
    DOC
    But I need like below...
    PartnerOrderNumber
    H DateTime
    R DateTime
    Tracking Number
    Document
    PO1
    1 am
    3 am
    123
    DOC
    PO1
    2 am
    246
    DOC
    PO2
    4 am
    6 am
    678
    DOC
    PO2
    5 am
    890
    DOC
    PO2
    7 am
    8 am
    001
    DOC
    PO3
    9 am
    11 am
    008
    DOC
    PO3
    10 am
    065
    DOC
    PO3
    12 pm
    2 pm
    636
    DOC
    PO3
    1 pm
    978
    DOC
    My aim is to get H datetime in one column and R datetime in another column but only in 1st row of H datetime. PO3 has H H R H H R so each R datetime should be in 1st of H datetime.
    Thanks in Advance,
    Sindhu

    This forum is for the SQL Developer tool, not for general SQL or PL/SQL questions.  The clue is in the name. 
    Try asking in the Database General or SQL and PL/SQL forums.

  • Getting rid of gap  between title banner image  and Spry Menu bar?

    Hi,
    Here's what I have so far :
    http://www.artbywaqas.com/TEST/index.html
    How can I get rid of the gap between the banner image and the menu below it?

    Please explain, what is the center element as in line 43 with the closing tag on line 94?
    Also, wrapping the banner image in a paragraph element ensures that you will have a margin and/or padding above and below the element unless you specifically change the style rules to eleminate the marging and/or padding.
    The quickest solution is to remove the center element (which does not exist) and change the paragraph elemnt to a div element.
    Gramps

  • Getting rid of gaps in iMovie 09 file import

    When I import a project from DV to iMovie 09, how do I get rid of the gaps put there between clips by iMovie? I don't want any gaps as my DV already has the finished cut of the project.

    I'm having a similar problem. Back in my PC days, I edited an entire project on Pinnacle Studio Ultimate HD. Exported the entire 71 minutes movie back on HDV tape. Now I have my Macbook Pro, and am trying to import the finished product into iMovie so I can tinker a bit with it, and ultimately burn it using iDVD. Yet when I import off my Canon Vixia HV30, all of the clips are completely rearranged with annoying gaps in between where one clip begins and ends. How do I change the settings to simply import the HDV as is? I really don't want to have to drag every clip into my timeline and then rearrange them all into the original order.

  • How to get  generic delta using timestamp field

    Hi All,
    i have created a generic datasource using tables vbrp,vbrk.mara,marc,knvv.. to get the sales data for planning.Here i have document created date and time.So i'm concatinating these 2 date and time fields into timestamp which is of format yyyymmddhhmmss.Finally i'm using this timestamp to extract data .
    So is it the right way to pull the data using timestamp and what is the timezone i need to specify as the servers are in india only.
    or any other way to proceed.
    Thanks
    Rao.

    Hi Rao,
    Delta based on timestamp based on generic datasource only works if any one of the tables contains timestamp field(not time and date fields separately).
    I dont think by combining date & time fields will give you correct results.
    Regarding time zone: Use SAP system time zone.
    Srini

  • How do I get rid of gaps between songs??

    Hi,
    I am trying to record a mix CD into iTunes but there are gaps between songs.
    I know that you can take these gaps out by making the CD into one long track on your ipod, but is there anyway I can get rid of the gaps and keep them as seperate tracks, like on the CD?

    In the burning options, change the time between tracks from two seconds to zero seconds.

Maybe you are looking for

  • Lame-3.96.1-2.pkg.tar.gz with MMX/3DNow!/SSE support

    Hi! I may be a lamer, but the lame 3.96 version doesn't seem to be compiled with (asm) CPU optimalization. Or it just doesn't show during encoding. But if you have an i686 CPU, it has MMX support(?). So anyone who uses i686 can run MMX optimized prog

  • Editing a Payment Proposal to remove payment block

    I am running a payment proposal in which I have a document which is blocked for payment.  I have removed the payment block by editing the payment proposal (change line items screen).  When ticking the change, rather than going back to the edit paymen

  • How to use  _root to load file from HDD

    I have main moviclip.Inside this movieclip I have 2 layers. On the 1st keyframe of layer1 I have _root to moviclip to load [ _root.section != "a.swf"; { _root.section = "a.swf"; _root.transition.gotoAndPlay("closing"); ] thing is this is not leading

  • Possibility to set default border to zero

    Hi there, I noticed that hardly any designer is using borders for the elements he is creating. Though in Muse the borders are set by default already, and we have to change it with every element we add, again and again. Especially all the states of al

  • Duplicate Contact Overload

    For some reason, my contacts list has exploded.  I have one phone number in my contact list over 1,000 times.  In all, I have 22,348 contacts in my phone.  Clearly, there is something wrong!  How can I delete the duplicates quickly?