Begin time and End time calculation from timestamp

Dear all,
I have a below input,
Channel_number
GPS_TIME
5815
2013-05-13 18:56:46.410000
5815
2013-05-13 18:56:47.410000
5815
2013-05-13 18:56:48.410000
5815
2013-05-13 18:56:49.410000
5780
2013-05-13 18:56:49.510000
5780
2013-05-13 18:56:50.410000
5780
2013-05-13 18:56:51.410000
5815
2013-05-13 18:56:51.510000
5815
2013-05-13 18:56:52.410000
I am trying to get the output like below,
CHANNEL_NUMBER
BEGIN_TIME
END_TIME
5815
2013-05-13 18:56:46.410000
2013-05-13 18:56:49.410000
5780
2013-05-13 18:56:49.510000
2013-05-13 18:56:51.410000
5815
2013-05-13 18:56:51.510000
2013-05-13 18:56:52.410000
Please help me out to get this.
Thanks All

with
the_data as
(select 5815 channel_number,to_timestamp('2013-05-13 18:56:46.410000','yyyy-mm-dd hh24:mi:ss.ff') gps_time from dual union all
select 5815,to_timestamp('2013-05-13 18:56:47.410000','yyyy-mm-dd hh24:mi:ss.ff') from dual union all
select 5815,to_timestamp('2013-05-13 18:56:48.410000','yyyy-mm-dd hh24:mi:ss.ff') from dual union all
select 5815,to_timestamp('2013-05-13 18:56:49.410000','yyyy-mm-dd hh24:mi:ss.ff') from dual union all
select 5780,to_timestamp('2013-05-13 18:56:49.510000','yyyy-mm-dd hh24:mi:ss.ff') from dual union all
select 5780,to_timestamp('2013-05-13 18:56:50.410000','yyyy-mm-dd hh24:mi:ss.ff') from dual union all
select 5780,to_timestamp('2013-05-13 18:56:51.410000','yyyy-mm-dd hh24:mi:ss.ff') from dual union all
select 5815,to_timestamp('2013-05-13 18:56:51.510000','yyyy-mm-dd hh24:mi:ss.ff') from dual union all
select 5815,to_timestamp('2013-05-13 18:56:52.410000','yyyy-mm-dd hh24:mi:ss.ff') from dual
select channel_number,begin_time,end_time
  from (select gr,
               channel_number,
               first_value(gps_time) over (partition by gr order by gps_time) begin_time,
               first_value(gps_time) over (partition by gr order by gps_time desc) end_time,
               row_number() over (partition by gr order by gps_time) rn
          from (select channel_number,gps_time,
                       row_number() over (order by gps_time) - row_number() over (partition by channel_number order by gps_time) gr
                  from the_data
where rn = 1
order by begin_time
CHANNEL_NUMBER
BEGIN_TIME
END_TIME
5815
13-MAY-13 06.56.46.410000000 PM
13-MAY-13 06.56.49.410000000 PM
5780
13-MAY-13 06.56.49.510000000 PM
13-MAY-13 06.56.51.410000000 PM
5815
13-MAY-13 06.56.51.510000000 PM
13-MAY-13 06.56.52.410000000 PM
Regards
Etbin
Message was edited by: Etbin me and/or Apex we messed something up in the original post

Similar Messages

  • Beginning Balance and Ending Balance Calculation

    Hi all,
    I have got a critical requirement for my report.
    I have to calculate Opening and Closing Balances for every month
    Beginning balance amount of current month = Ending balance amount of previous month.
    and Ending Balance = Beginning Balance + Transactions(data available)
    My Beginning Balance amount initially will be loaded from Flat file.
    For the first month I will go with a calculated Keyfigure and calculate my ending Balance.
    Now, this ending balance of current month will be beginning balance of next month.
    The problem is for the second month if i want ending balance, how to hold that data, as that is a calculation.
    Secondly, if the data is for current period..that's fine, but if i have to see previous months data, how to get it??
    Thanks,
    Hima.

    Make a cell reference to the previous month in your query designer. I don't have any specific information available at this point, but I have done the exact same thing in the past and we could make it working using cell references. There's enough documentation available if you want to know the ins&outs of this.

  • How Do I Filter a Report Using a Multi Select List Box and Specifying Date Between Begin Date and End Date

    Hope someone can help.  I have tried to find the best way to do this and can't seem to make sense of anything.  I'm using an Access 2013 Database and I have a report that is based on a query.  I've created a Report Criteria Form.  I
    need the user to be able to select multiple items in a list box and also to enter a Begin Date and End Date.  I then need my report to return only the records that meet all selected criteria.  It works fine with a ComboBox and 1 selection but can't
    get it to work with a List Box so they can select multiple items.  Any help is greatly appreciated while I still have hair left. 

    The query should return all records.
    Let's say you have the following controls on your report criteria form:
    txtStart: text box, formatted as a date.
    txtEnd: text box, formatted as a date.
    lbxMulti: multi-select list box.
    cmdOpenReport: command button used to open the report.
    The text boxes are used to filter the date/time field DateField, and the list box to filter the number field SomeField.
    The report to be opened is rptReport.
    The On Click event procedure for the command button could look like this:
    Private Sub cmdOpenReport_Click()
    Dim strWhere As String
    Dim strIn As String
    Dim varItm As Variant
    On Error GoTo ErrHandler
    If Not IsNull(Me.txtStart) Then
    strWhere = strWhere & " AND [DateField]>=#" & Format(Me.txtStart, "yyyy-mm-dd") & "#"
    End If
    If Not IsNull(Me.txtEnd) Then
    strWhere = strWhere & " AND [DateField]<=#" & Format(Me.txtEnd, "yyyy-mm-dd") & "#"
    End If
    For Each varItm In Me.lbxMulti.ItemsSelected
    strIn = strIn & "," & Me.lbxMulti.ItemData(varItm)
    Next varItm
    If strIn <> "" Then
    ' Remove initial comma
    strIn = Mid(strIn, 2)
    strWhere = strWhere & " AND [SomeField] In (" & strWhere & ")"
    End If
    If strWhere <> "" Then
    ' Remove initial " AND "
    strWhere = Mid(strWhere, 6)
    End If
    DoCmd.OpenReport ReportName:="rptMyReport", View:=acViewPreview, WhereCondition:=strWhere
    Exit Sub
    ErrHandler:
    If Err = 2501 Then
    ' Report cancelled - ignore
    Else
    MsgBox Err.Description, vbExclamation
    End If
    End Sub
    If SomeField is a text field instead of a number field, change the line
            strIn = strIn & "," & Me.lbxMulti.ItemData(varItm)
    to
            strIn = strIn & "," & Chr(34) & Me.lbxMulti.ItemData(varItm) & Chr(34)
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • How to retrieve start and end date values from sharepoint 2013

    Hi,
    How to retrieve start and end date values from new event form of calendar in SharePoint foundation2013
    Thanks
    Gowri Balaguru

    Hi Srini
    Yes i need to have parallel flow for both and in the cube where my reporting will be on monthly basis i need to read these 2 master data and get the required attributes ( considering last/first day of that month as per the requirement).......but i am just wondering this is common scenario....while there are so many threads written for populating 0employee from 0person......don't they have such requirement.....
    Thanks
    Tripple k

  • Time calculation from one date to some other date

    Hello,
    I want to time calcualtion from one date to other date period.
    for calculating total hr's from one date to other date.plz let me know the logic.
                           Date                      Time
    Eq:  1st date:   22.05.2008             01.10.00
          2nd date:   25.05.2008             12.10.00
    I want the total hrs from 22.05 to 25.05 like i need result as
    from 22 to 25 total hrs based on the time given.

    Hello,
    Instead of FM..We can achieve by the following program...
    REPORT YRT_TEST1.
    parameters : date1 like sy-datum,
    date2 like sy-datum.
    data: days(3) type n.
    data: years(10) type p decimals 3.
    start-of-selection.
    days = date2 - date1.
    years = days / 365.
    write: / days,
    years.
    Now Multiply 24  to days to get hours and the multiply with 60*60 to get the seconds
    ***************Reward points,if found useful

  • Infotype for Employee begin date and end date

    Hi Friends,
    Could any one tell me the infotype and fields for getting employee joining date and end date.
    Regards,
    Susmita.

    Infotype 41 (Date Specifications) should have all dates.
    Infotype 2...i.e. PA0002 BEGDA & ENDDA may not have actual start and end date depending on how your company maintains it.
    In Infotype 41 (table PA0041)...get either BEGDA & ENDDA or get correct date based on qualifier DAR01-DAR12.
    Thanks,
    Pushpinder Randhawa

  • Delivery time calculation from purchase info records in MRP

    Hi experts.
    I am using MRP -manual reorder point planning . I have maintain the delivery lead time as 10 days . This material has a info-record for a vendor and a contract also. we maintain the delivery time for the supplier is 20 days in the info records. And a source list is also maintain for this material with reference to the contract and assigned as MRP relevant.
    We run  MRP of this material and create the PR directly.
    we run ME59N for automatic creation of PO also.
    what I see is the delivery time defined in the PR is consider as 10 days from the material master MRP view. But when we convert the PR to PO the delivery time is updated from the inforecord. but the delivery date in the PO line item is not update. It is showing the same delivery date as PR.
    Is it possible to update the delivery date bas eon the info record when we convert from PR to PO automatically?
    regards
    DP

    I don't know the answer to your question, but can point you in another direction; you can set the system up in such a way that already MRP (as per the way you have described that you work) will take into consideration the planned delivery from the Info record/Contract:
    In transaction OPPQ check the "Scheduling: Info Rec/Agreement" box!
    This will make MRP take the planned delivery time from the IR or Agreement, whenever the source (vendor) is identified during the MRP run.
    Regards,
    Mario

  • How can i get the begin date and end date of some week in some year

    I only know the week number within the current year.

    hi,
    you should completely learn the class "java.util.Calendar", ant then, you can solve your problem easily.
    If you cannot solve after learning the class, I will tell you the answer.

  • Inventory Management 0IC_C03: Beginning and ending inventory

    Hi Gurus
    My report is based on Inventory Management cube and I have a requirement where in I need to show Begining Inventory and Ending Inventory for Plant per Period.
    There is no KF for Beginning Invin SAP standard model in inventory management cube (0IC_C03 cube), so I thought to restricting total quantity by Fiscal period and Offset by minus one to get begining inventory.
    Here is my report layout:
    I have got : Period , Plant in rows and Beginning and ending inventory in Columns.
    Desired Output:
    Fiscal Period | Plant |  |  Begining Inventory | Ending Inventory.
    03/2009        |  1001 |    100                       |  50
    Actual Report output
    Fiscal Period | Plant |  |  Begining Inventory | Ending Inventory.
    02/2009        |  1001 |                 100          | 
    03/2009        |  1001 |                                |  50
    So basically report is being split on two lines for current and previous (due to restriction in begining period : Offset =-1 on period).
    Question is how to achieve both begining and ending inventory for a period in same line.
    Thanks in avdance for help and time
    SA

    HI Naveen
    Thanks for the reply. Non *** KF are already being used and Standard SAP model is being followed. Problem is not with back end but with frontend. Data coming on the report is fine but problem is how to show them on same line. Remember Beginning inventory for current open is ending inventory for previous month and  in SAP content there is no KF called as begining inventory. Basically data from two consecutive periods (current and previous one) needs to be on same row of report, but they are coming on different rows if we have period in drilldown by period. this makes sense but how to overcome this.
    This, We have all the correct data but facing issue while displaying that on frontend.
    Thanks
    Sorabh
    Edited by: Sorabh on Mar 23, 2009 5:01 PM

  • SAP CRM Tables and Fields for Contract start and End dates

    Hi Experts,
    Please Provide me SAP CRM Tables and Field names for the below.
    SAP CRM Contracts start date and End date
    SAP CRM Conditions(PROO, K007 etc....) records start and End Date.
    Thanks and Regards,
    Teja

    correction
    10 Replies Latest reply: 24 May, 2013 8:38 AM by nishant Vasudev  
    Tweet
    SAP CRM Tables and Fields for Contract start and End dates
    This question has been Answered.
    Teja Dhar 12 Oct, 2009 8:03 PM  
    Currently Being Moderated
    Hi Experts,
    Please Provide me SAP CRM Tables and Field names for the below.
    SAP CRM Contracts start date and End date
    SAP CRM Conditions(PROO, K007 etc....) records start and End Date.
    Thanks and Regards,
    Teja
    Correct Answer by Sreekantha Gorla  on Oct 22, 2009 8:22 PM
    Hi,
    dates will be stores in the table 'SCAPPTSEG'.
    I double checked it. This table stores all the date types of one order transactions...
    The relationship is as follows..
    CRMD_ORDERADM_H- guid = crmd_link-guid_hi
    crmd_link-guid_set = SCAPPTSEG-APPL_GUID.
    Thanks and regards,
    Sreekanth
    <:footer>See the answer in context
    6281 Views
    Topics: Customer Relationship Management
    Reply
    Average User Rating
    0
    (0 ratings)
    My Rating:
      Rating Saved!
    Comment on your rating
      Re: SAP CRM Tables and Fields for Contract start and End dates
    Robert Jesionowski 14 Oct, 2009 2:23 PM (in response to Teja Dhar)  
    Currently Being Moderated
        Hi, 
    you should try with FM: CRM_DATES_READ_SINGLE_OB or CRM_DATES_READ_DB.
    There is something in table SCAPPT and SCGENAPPT.
    Regards, R
    Report Abuse
    Like (0)
    Reply
      Re: SAP CRM Tables and Fields for Contract start and End dates
    Teja Dhar 22 Oct, 2009 5:30 PM (in response to Robert Jesionowski)  
    Currently Being Moderated
        Hi Robert, 
    I am not able to find contract start date and End dates in the tables SCAPPT and SCGENAPPT.
    Can you suggest some relevant tables.
    Best Regards,
    Teja
    Report Abuse
    Like (0)
    Reply
      Re: SAP CRM Tables and Fields for Contract start and End dates
    Sreekantha Gorla 22 Oct, 2009 2:35 PM (in response to Teja Dhar)  
    Currently Being Moderated
        Hi, 
    Table SCAPPTSEG stores the contract start and end dates.
    Thanks,
    Sreekanth
    Report Abuse
    Like (0)
    Reply
      Re: SAP CRM Tables and Fields for Contract start and End dates
    Teja Dhar 22 Oct, 2009 5:32 PM (in response to Sreekantha Gorla)  
    Currently Being Moderated
        Hi Sreekanth, 
    I am not able to find contract start date and End dates in the table SCAPPTSEG.This is for appointments.
    Can you suggest some relevant tables.
    Best Regards,
    Teja
    Report Abuse
    Like (0)
    Reply
    Correct AnswerRe: SAP CRM Tables and Fields for Contract start and End dates
    Sreekantha Gorla 22 Oct, 2009 8:22 PM (in response to Teja Dhar)  
    Currently Being Moderated
        Hi, 
    dates will be stores in the table 'SCAPPTSEG'.
    I double checked it. This table stores all the date types of one order transactions...
    The relationship is as follows..
    CRMD_ORDERADM_H- guid = crmd_link-guid_hi
    crmd_link-guid_set = SCAPPTSEG-APPL_GUID.
    Thanks and regards,
    Sreekanth
    Report Abuse
    Like (0)
    Reply
      Re: SAP CRM Tables and Fields for Contract start and End dates
    Wim Olieman 23 Oct, 2009 9:12 AM (in response to Sreekantha Gorla)  
    Currently Being Moderated
        Hi, 
    I can tell you where the pricing records are saved, replicated from ECC.
    The data from ECC table Axxx (e.g. A304) is replicated to CRM table
    CNCCRMPRSAPxxx (e.g. CNCCRMPRSAP304).
    Here you can find fields TIMESTAMP_TO and TIMESTAMP_FROM.
    About the dates: what Sreekantha Gorla stated, about table 'SCAPPTSEG' is correct.
    What might help is to execute program "CRM_ORDER_READ". Here you can find
    the relevant entries also.
    regards,
    Wim
    Report Abuse
    Like (0)
    Reply
      Re: SAP CRM Tables and Fields for Contract start and End dates
    Teja Dhar 23 Oct, 2009 4:59 PM (in response to Teja Dhar)  
    Currently Being Moderated
        Hi Experts, 
    Thanks a lot for your support.My problem got resolved.
    Best Regards,
    Teja
    Report Abuse
    Like (0)
    Reply
      Re: SAP CRM Tables and Fields for Contract start and End dates
    rajesh gadamsetty 27 Nov, 2009 12:29 PM (in response to Teja Dhar)  
    Currently Being Moderated
        Hi Teja 
    Please let me know how you got the dates. i got the same requirement
    Report Abuse
    Like (0)
    Reply
    Correction on above mail.
    Hi Sanjay,
    Can you please help me to find the contract st art date and end date fetching from the table as below
    ITEM DATES:
    Select guid_set from table CRMD_LINK where guid_hi              =  CRMD_ORDER_I-GUID AND
                                                                              OBJTYPE_HI     =  '06'
                                                                              OBJTYPE_SET  =  '30'.
    Select * from SCAPPTSEG where APPL_GUID = guid_set.
    as from the table scapptseg has some unusal fields which fields to select to get the start date and end date and on what condition and isuppose we need to convert als the same
    pls suggest further on same
    regards
    Arora

  • Is there a way I can have my form calculate a total time from beginning and ending time?

    Is there a way I can have my form calculate a total time from beginning and ending time?

    Sorry, but Formscentral doesn't support either a timer function or any kind of calculation. You might be able to do this if created your form in PDF. For help with PDF form creation in Acrobat I suggest you repost your question to the Acrobat Forum.
    Andrew

  • I've updated to yosemite from Mavericks, but since i can't connect to the internet I used my time machine back up which was march 2013. Now my macbook pro won't start and ends with a prohibited ted sign. Any suggestions pls.

    I've updated to yosemite from Mavericks, but since i can't connect to the internet I used my time machine back up which was march 2013. Now my macbook pro won't start and ends with a prohibted sign. Any suggestions pls.

    Install or Reinstall Yosemite, Mavericks, Mountain Lion, or Lion from Scratch
    Be sure you backup your files to an external drive or second internal drive because the following procedure will remove everything from the hard drive.
    How to Clean Install OS X Yosemite
    OS X Mavericks- Erase and reinstall OS X
    OS X Mountain Lion- Erase and reinstall OS X
    OS X Lion- Erase and reinstall Mac OS X
    Note: You will need an active Internet connection. I suggest using Ethernet if possible
                because it is three times faster than wireless.

  • Beginning and ending playhead indicator in canvas at same time?

    I noticed a stutter after burning my project. When I go back to the edit in FCP I notice that where the stutter is one clip shows both the beginning indicator and the ending indicator at the same time...then the next clip shows just the beginning indicator? I have tried to re-enter the clips... and they are not overlapping??? No help...The field dominance is consistant at Lower? Any ideas?

    I searched down the timline and found an audio track
    that ended one frame too soon...extended it and it
    corrected the indicator problem...won't know if it
    corrected the stutter until I burn it aga
    When you said "stutter" I assumed that you meant like a video glitch such as a frame of video that creates a "jumpy" look at that spot in the timeline. Have we been talking about an audio stutter?
    Compressing out to DVD shouldn't make the difference. Compression creates and MPEG2 and AIFF file suitable for DVDSP, but it doesn't create "stutters" That's either in the timeline or it isn't.

  • Select Records between Begin Date/Time and End Date/Time

    Hi, I need to select records from table GLPCA where the CPUDT and CPUTM are between a START DATE/TIME and END DATE/TIME. 
    I have the below logic from an SAP Solution, but it doesn't seem to be working right in my opinion.  It is picking up records earlier than the date ranges.  Can anyone tell me how I might be able to accomplish this?  I'm hoping this is an easy one for the ABAPPERs... 
    Thanks,
    START DATE 20091022
    START TIME 125736
    END DATE 20091022
    END TIME 135044
    CPUDT 20091022
    CPUTM 100257
          SELECT * FROM GLPCA
             WHERE ( CPUDT >= STARTDATE AND ( CPUTM >= STARTTIME OR ( CPUDT <= ENDDATE AND CPUTM <= ENDTIME ) ) ).

    Thank you all!  I ended up using the following:
    SELECT * FROM GLPCA
              WHERE RYEAR IN L_R_RYEAR
                AND ( ( CPUDT = STARTDATE AND CPUTM >= STARTTIME ) OR CPUDT > STARTDATE )
                AND ( ( CPUDT = ENDDATE   AND CPUTM <= ENDTIME )   OR CPUDT < ENDDATE ).
    This child was born from the following thread that was found:
    update date and time of client record

  • How to determine minutes per week with inconsistent start and end times...

    ver -> 10.2.0.4
    I'm looking for some guidance or some pseudo code in how to attack the following:
    Data
    target_nm  status       start_timestmap       end_timestamp
    DEVDB      Target Up    8/28/2009 9:49:08 AM  9/26/2009 6:34:23 PM
    DEVDB      Target Down  9/26/2009 6:34:23 PM  9/26/2009 6:36:23 PM
    DEVDB      Target Up    9/26/2009 6:36:23 PM How can I display, per week, the number of minutes a status was held? There are 10,080 minutes per week and I'm using to_char(to_date('8/28/2009 9:49:08 AM', 'mm/dd/yyyy hh:mi:ss AM'), 'WW') to determine the week number. The end result would be something like, in example:
    target_nm   wk    up           down
    DEVDB       35    [x minutes]  [y minutes]This, at first, seemed pretty straight forward, but where it gets wrapped around the axle is that the records of a status can span a number of weeks between the 'start_timestamp' and the 'end_timestamp.'
    My current approach is to isolate this down for a given day...if something is "started" then determine the number of minutes between trunc(start) +1 and start . If it has "ended" then determine the number of minutes between trunc(ended) and end.
    Resulting in something like:
    target_nm    status     day_of_year  minutes_of_status start_timestamp       end_timestamp
    DEVDB        Target Up  8/27/2009    296.3333          8/27/2009 7:03:40 PM  nullAny advice, a different perspective, or pseudo code would be greatly appreciated on how to turn the corner on showing these status's as they break down per week.
    Regards,
    -abe

    Hi,
    As you said, you just need to compute SUM (end_timestamp - start_timestamp), GROUPing BY week.
    The tricky part is what happens when an event is not entirely within one week. For example:
    DEVDB      Target Up    1/07/2009 11:00:00 AM  1/08/2009 2:00:00 PMThis event lasted 3 hours, but you want to count this as 1 hour in week '01', and 2 hours in week '02', not as 3 hours in either week.
    The solution is very much like the one in the following thread:
    [8i] Date/Time calculation problem...
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
    Edited by: Frank Kulash on Mar 16, 2010 12:16 PM

Maybe you are looking for

  • The music in my iTunes library won't sync to my iPod touch

    I have a 32 GB 3rd iPod touch. And earlier after I had finished downloading some new music, I tried to sync my iPod. First it told me I had to restore my iPod, because it couldn't be read. I did. And three hours later, it was done. So once again, I p

  • Premiere Pro CC 2014 crashes when loading project file

    Hi guys, any help on this is much appreciated as I have a job due in 18 hours and I'm in big trouble if I can't fix this. I've been editing a project in Adobe Premiere Pro CC 2014 (updated to the latest version) and when I tried to access the same fi

  • Exploring and editing pdf metadata

    Adobe FOrm Looking for either an Adobe or third party solution such that I can explore and edit my pdf metadata.  I have hundreds of technical and journal documents 9somewhat organized).  But search for a particular article can be a daunting experien

  • Loading the site

    Hello, is there any who know how to load the site by itself (the swf). I don't speak about loading an external source (jpg, mp3, xml, etc...) in AS2 it was with getBytesLoaded and getBytesTotal in AS3 it seems to be bytesTotal from URLLoader class bu

  • GPU Acceleration. Which one to choose for Premiere CC: CUDA or OpenCL?

    If anyone has any experience regarding CUDA vs OpenCL acceleration in Premiere Pro CC, I would really appreciate your thoughts on this: I have a Sager 8270 laptop with an nVidia GTX770M video card with 3GB GDDR5 VRAM that I need to exchange since the