Splitting rows at specific times (not intervals)

Greetings.
I have a data set with fields that hold start and end times for specific events. These events have unique ID's and cross multiple time intervals. I'm looking for a way to split a single row in the dataset into multiple rows with new start and end times for each relevant time interval.
The examples I've found online describe ways (using the MODEL method) to split rows based on time intervals of a fixed length (24 hours, for example) but I'm looking for a way to split the records at a specific time (at 6am and 6pm.)
So this record set:
<tt>SELECT ID, START_DATE, END_DATE FROM EVENTTABLE
_ ID __________ Start_date __________ End Date _____
1228322 __ 21-NOV-11 17:51:29 __ 21-NOV-11 19:32:27
1228327 __ 21-NOV-11 14:53:24 __ 22-NOV-11 03:46:06
1228334 __ 21-NOV-11 03:32:53 __ 21-NOV-11 05:13:13
1183267 __ 25-SEP-11 16:09:13 __ 27-SEP-11 04:38:11</tt>
Would become:
<tt>SELECT ID, START_DATE, END_DATE FROM EVENTTABLE MODEL...
_ ID __________ Start_date __________ End Date _____
1228322 __ 21-NOV-11 17:51:29 __ 21-NOV-11 18:00:00
1228322 __ 21-NOV-11 18:00:00 __ 21-NOV-11 19:32:27
1228327 __ 21-NOV-11 14:53:24 __ 21-NOV-11 18:00:00
1228327 __ 21-NOV-11 18:00:00 __ 22-NOV-11 03:46:06
1228334 __ 21-NOV-11 03:32:53 __ 21-NOV-11 05:13:13
1183267 __ 25-SEP-11 16:09:13 __ 25-SEP-11 18:00:00
1183267 __ 25-SEP-11 18:00:00 __ 26-SEP-11 06:00:00
1183267 __ 26-SEP-11 06:00:00 __ 26-SEP-11 18:00:00
1183267 __ 26-SEP-11 18:00:00 __ 27-SEP-11 04:38:11</tt>
Notice that record 1183267 starts in one interval, crosses two whole intervals and ends in a fourth. This splitting of one event into many is required to create a record set that will guarantee a record for each of the relevant intervals.
Thanks in advance for your consideration!

SonyDADCuser wrote:
Greetings.
I have a data set with fields that hold start and end times for specific events. These events have unique ID's and cross multiple time intervals. I'm looking for a way to split a single row in the dataset into multiple rows with new start and end times for each relevant time interval.
The examples I've found online describe ways (using the MODEL method) to split rows based on time intervals of a fixed length (24 hours, for example) but I'm looking for a way to split the records at a specific time (at 6am and 6pm.)
So this record set:
<tt>SELECT ID, START_DATE, END_DATE FROM EVENTTABLE
_ ID __________ Start_date __________ End Date _____
1228322 __ 21-NOV-11 17:51:29 __ 21-NOV-11 19:32:27
1228327 __ 21-NOV-11 14:53:24 __ 22-NOV-11 03:46:06
1228334 __ 21-NOV-11 03:32:53 __ 21-NOV-11 05:13:13
1183267 __ 25-SEP-11 16:09:13 __ 27-SEP-11 04:38:11</tt>
Would become:
<tt>SELECT ID, START_DATE, END_DATE FROM EVENTTABLE MODEL...
_ ID __________ Start_date __________ End Date _____
1228322 __ 21-NOV-11 17:51:29 __ 21-NOV-11 18:00:00
1228322 __ 21-NOV-11 18:00:00 __ 21-NOV-11 19:32:27
1228327 __ 21-NOV-11 14:53:24 __ 21-NOV-11 18:00:00
1228327 __ 21-NOV-11 18:00:00 __ 22-NOV-11 03:46:06
1228334 __ 21-NOV-11 03:32:53 __ 21-NOV-11 05:13:13
1183267 __ 25-SEP-11 16:09:13 __ 25-SEP-11 18:00:00
1183267 __ 25-SEP-11 18:00:00 __ 26-SEP-11 06:00:00
1183267 __ 26-SEP-11 06:00:00 __ 26-SEP-11 18:00:00
1183267 __ 26-SEP-11 18:00:00 __ 27-SEP-11 04:38:11</tt>
Notice that record 1183267 starts in one interval, crosses two whole intervals and ends in a fourth. This splitting of one event into many is required to create a record set that will guarantee a record for each of the relevant intervals.
Thanks in advance for your consideration!Neat problem.
This assumes you have a reasonably recent version of Oracle, and i only tested it for your "complex" case spanning multiple days because i didn't want to type out a bunch of sample data. Should work on all your data sets though (i always say this when i do incomplete testing :).
with
  time_data as
  select
      1                                                         as col1
    , to_date('25-sep-2011 16:09:13', 'dd-mon-yyyy hh24:mi:ss') as start_date
    , to_date('27-sep-2011 4:38:11', 'dd-mon-yyyy hh24:mi:ss')  as end_date
  from dual
select *
from
  select
      col1
    , greatest
          trunc(t.start_date, 'dd') - interval '6' hour + (interval '12' hour * m.column_value)
        , t.start_date
      ) as start_date
    , least
          trunc(t.start_date, 'dd')  + interval '6' hour + (interval '12' hour * m.column_value)
        , t.end_date
      ) as end_date
  from time_data t,
    table(cast(multiset(select level from dual connect by level <= ceil(end_date - start_date) * 2) as sys.odcinumberlist)) m
where start_date < end_date;

Similar Messages

  • Countdown to a specific time (Not Midnight)

    Hello All;
    I have to quickly make a countdown timer for a website that counts down to a specific date & time (Not midnight). I need like May 4th, 2011 at 9:10 AM.
    I used a tutorial to create a timer that counts down to midnight but need to modify it to countdown to a specific time other than midnight.
    Below is the code. Can anyone help me modify the code below. Thanks.
    Tim
    var today:Date = new Date();
    var currentYear = today.getFullYear();
    var currentTime = today.getTime();
    var targetDate:Date = new Date(currentYear,1,12);
    var targetTime = targetDate.getTime();
    if (targetTime <= 0) {
      gotoAndStop(3);
    var timeLeft = targetTime - currentTime;
    var sec = Math.floor(timeLeft/1000);
    var min = Math.floor(sec/60);
    var hrs = Math.floor(min/60);
    var days = Math.floor(hrs/24);
    sec = String(sec % 60);
    if (sec.length < 2) {
      sec = "0" + sec;
    min = String(min % 60);
    if (min.length < 2) {
      min = "0" + min;
    hrs = String(hrs % 24);
    if (hrs.length < 2) {
      hrs = "0" + hrs;
    days = String(days);
    var counter:String = days + ":" + hrs + ":" + min + ":" + sec;
    time_txt.text = counter;

    I haven't looked at the rest of the code, but if you say it works, then all you really need to do is adjust the targetDate arguments.
    The constructor for a Date object is...
    Date(year, month, date, hour, minute, second, millisecond)
    so just fill in the data you need instead of what you have....
    var targetDate:Date = new Date(year, month, date, hour, minute, second, millisecond);

  • Reboot at a specific time not working in Yosemite?

    Since moving a couple of our servers to Yosemite I have been unable to get them to actually reboot at a specific time as requested via System Preferences > Energy Saver > Schedule.
    10.9 servers reboot on their own fine. 10.10 has required a manual reboot since installing it on two late silver model Mac Pros and on one Mac Mini Server.
    Ideas? Thanks.

    While in Time Machine, press the key combination shift-command-C. The front window will show all mounted volumes. All snapshots should now be accessible. Select the one you want and navigate to the files you want to restore.

  • Events with specific time not showing on my ipad or iPhone... only on my iMAC... all day events show up

    When I look at my icloud calendar on my MAC, everything is there... when I go to my iPhone or iPad... the timed events are missing.  The all day events do show up?   HELP?

    Duplicates are due to syncing both with iCloud AND with iTunes.  Turn off calendar syncing in iTunes.
    I don't know what you mean by "removed some from my mibile devices".  Are you sayig some calendars are gone on some devices that have been registered with iCloud?

  • How to mask out specific area in a specific time?

    Hi,
    I want to make a mask on a specific area of the footage in a specific time. I drew the mask and all the frame went black,so I clicked on Mask-> invert and only the specific area I masked went black,which is exactly what I wanted.
    Now I want to make it happen in a specific time, not on all timeline, but I can't find a way to do it. I thought about lowering down the mask opacity to 0% and a frame later bringing it to 100%, but if I lower down the opacity of the mask, it lowers down the opacity of the whole frame, same as
    lowering down the opacity of the frame by intention, which seems weird, cause I did inverted the mask, and as I understand it, it should affect the opacity of the mask and not the whole frame...
    any ideas...?
    I'm using CS4.

    Put a copy of the footage on the timelime below the one you masked. Use opacity like you doing and it will reveal the track below.

  • Add not 1 but 2 to 3 rows at a time?

    I have worked hard at my project and with my question can someone help me in which no one did. Maybe it is because it was too long and the length of the code was throwing people off. That wasn't the whole code. Anyways I have managed to add 1 row to the from table. I makes me happy to see it work. But my leader is not satisfied yet. He wants to see the program adding several rows at a time.
    function addRow()
            var tbody = document.getElementById("table2").getElementsByTagName("tbody")[0];
            var row = document.createElement("TR");
                    var cell1 = document.createElement("TD");
                                  cell1.innerHTML = "Ïä×ӳߴç";
                    var cell2 = document.createElement("TD");
                                  var inp1 =  document.createElement("INPUT");
                                  var inp2 =  document.createElement("INPUT");
                                  var inp3 =  document.createElement("INPUT");
                                  var inp4 =  document.createElement("INPUT");
                                  cell2.innerHTML = "³¤£º";
                            inp1.setAttribute("type","text");
                            inp1.setAttribute("value","");
                                  inp1.setAttribute("size" ,"8");
                            cell2.appendChild(inp1);
                                  cell2.appendChild(document.createTextNode("Ó¢´ç ¿í£º"));
                                  inp2.setAttribute("type","text");
                            inp2.setAttribute("value","");
                                  inp2.setAttribute("size" ,"8");
                            cell2.appendChild(inp2);
                                  cell2.appendChild(document.createTextNode("Ó¢´ç ¸ß£º"));
                                  inp3.setAttribute("type","text");
                            inp3.setAttribute("value","");
                                  inp3.setAttribute("size" ,"8");
                            cell2.appendChild(inp3);
                                  cell2.appendChild(document.createTextNode("Ó¢´ç"))
                                  inp4.setAttribute("type","text");
                            inp4.setAttribute("value","");
                                  inp4.setAttribute("size" ,"8");
                            cell2.appendChild(inp4);
                    var cell3 = document.createElement("TD");
                            cell3.innerHTML = "1Ó¢´ç = 2.5399ÀåÃ×"
              //Result
              row.appendChild(cell1);
            row.appendChild(cell2);
            row.appendChild(cell3);
            tbody.appendChild(row);This code adds 1 row, so the question is how i add another row within the same time as a click of 1 button. What i need to add to allow this to happen?
    Please kindly give a response, as any tips and words of wisdom is very much appreciated

    I am surprised by
    var row = document.createElement("TR");
    I would have expected
    var row = tbody.createElement("TR");

  • Deletion of arrays during specific time intervals...how to get it working?

    i am trying to calculate the average peak values in a systolic pressure waveform during a specific time interval. for example, every 5 seconds, i want to average out all the peak values in that interval and after calculating the average, i want to delete the array of peak values. however, what i am finding is that the array is always 0 if i use the delete array in my vi. therefore, the average is always NaN, because the array is empty and there is a divide by 0 error....
    what should i do? i have been stuck on it for a long time now, thankyou very much"
    Attachments:
    help.vi ‏57 KB

    It is very difficult to make sense of your diagram, because all the control references are missing, so it is not possible to tell the various data sources apart.
    Where is the data coming from? How do you prevent race conditions between the acquisition and analysis parts?
    Overall, the diagram is overly complicated and very hard to read. For example clearing the array does not require reading the old array, measuring it's length, followed by "delete from array", followed by writing back to the array. Why don't you just wire an empty array to it? Same result! :-)
    You go to tremedous lenght calculating a simple array average, using numerous property reads and indexing arrays inside FOR loops. There is "mean.vi" that does it in one step. (If you only
    have base LabVIEW, it might not be available (?), so use "Sum" and divide by n. No loop needed). To find the largest element in an array, use "Array Max & Min" from the array palette, again in one simple step.
    I would highly recommend going over some LabVIEW tutorials or look at some of the shipped examples. Make yourself familiar with basic programming concepts such as auto-indexing at loop boundaries. An "index array" wired to the loop counter is never needed.
    I suspect that your problem is due to a race condition between acquisition and analysis code, but there is no way to tell unless you include all control references and also the companion VI that gets the raw data from the instrument.
    LabVIEW Champion . Do more with less code and in less time .

  • My laptops QWERTY row of keys does not work for long periods at random intervals and only after pushing all the buttons on the row does it eventually turn back on and then will still cut out every now and again, anyone know how to solve this?

    My laptops QWERTY row of keys does not work for long periods at random intervals and only after pushing all the buttons on the row does it eventually turn back on and then will still cut out every now and again, anyone know how to solve this? If not is there any way to actually get a genuis appointment lol to get one of them to have a look at the hardware on the keyboard?

    Apple Support (formerly ExpressLane):
    https://getsupport.apple.com/GetproductgroupList.do
    https://getsupport.apple.com/GetSASO?SG=SG001&locale=en_US

  • Servlet that executes at specific time intervals ?

    Hi
    I need to have my Servlet that is loaded onto the webserver, run at specific time intrevals, say every 10 minutes.
    How do I do that ?
    Thanx in advance
    Aragorn

    I have trouble with this concept.
    HTTP is a request/response protocol. Usually a servlet runs when it receives an HTTP request and sends back an HTTP response.
    If you want the servlet to wake up and do something at a fixed interval, it's not responding to an HTTP request anymore. What does it do with the HTTP response that's generated? What happens if it receives an HTTP request from an external client after waking up and starting the timed process? Have you made sure that your servlet is thread-safe in that case?
    This feels less like a servlet and more like something else (e.g., an RMI service, EJB, or multi-threaded server). It sounds like you're using the servlet engine/container as a convenient service container, but I don't think servlets were meant to be used that way.
    I'll be happy to take instruction on this if I'm incorrect. I just thought I'd disagree to see what the response might be. Thanks - MOD

  • Not getting Yahoo emails on Q5 except for a specific time span

    My Q5 started to have this issue started about 4, 5 days ago. I dont get any Yahoo emails except for an approx 5 hr time span at specific times of the day.  All other times I do not get any emails at all, not even when pressing the "refresh" icon.  
    I have deleted / rebooted/re-added the yahoo account multiple times without any improvement. I have also tested for improvement by taking away the "rim." in the settings (IMAP and SMPT), no help.
     Well, right after re-adding the acct, the missing emails showed up, but that was it.  It doesn't update my emails until that specific time of the day (for me that time span is from midnight to ~5am).  I'm able to send out email fine.  
    Anyone has any suggestions?
    Thank you very much in advance.

    Re: Yahoo.ca email account information disappears or is not recognized
    ‎11-25-2013 08:53 PM
    The password disappeared again, so I changed the password as you suggested.
    I discovered that Yahoo had changed the password requirements, and that was likely causing the problem.
    (I wish the error message had been more specific so I would have known that was the issue earlier).
    I created a new password according to the new Yahoo password requirements, and I have not had any other problems with it so far.
    Thanks.
    It was not me it was user cb_ca and the above is what they posted. You can ask that user your question, just click the envelope icon on the middle of the page near the top and you can send them a message, just enter the users name mentioned above and type your message.

  • Not able to jump to a specific time on a music track (time slider has disappeared!)

    I don't know how it happened (update of iOS version?) but the time indicator saying how far into the music track as well as the time slider allowing me to 'scratch' to a specific time have both disappeared.
    Only the volume slider remains! How can I reinstate the time feature?

    thanks... i suddenly feel rather silly. although i swear i tried everything previously and it didn't work. oh well.

  • Selecting only one row at a time

    Hi experts,
    i have following doubt regarding selecting rows from a db:
    Is there any way of selecting only one row AT A TIME from a dabase just to collect the data in rows instead of in a unique document containing all the rows?
    I would like you to ellaborate on this as i need to send only one row to the IE, and then other row, and so on... without throwing any error!
    I have seen that there are SELECT SINGLE and SELECT UP TO 1 ROW, but these two methods are only useful when retrieving only one row, and that does not match my requirements. I need to process all the rows but one by one..
    I know that we can use the receiver jdbc adapter as if it was a sender by means of its specific datatype, but how to do it row by row??
    Hope i had explained well..
    Thanks in advance and best regards,
    David

    Hi kiran,
    Yes, my table has 5 not null fields but i am selecting and updating fixes values so i think that I will definetely go for the next solution:
    SELECT * FROM t1 WHERE status='0' and ROWNUM<2;
    UPDATE t1 SET status='1' WHERE status='0' and ROWNUM<2;
    My only concern is if the update will take the same row that the select.... BTW, I think it will
    ..What do you guys think?
    I ve been trying to operate with your proposed queries but i received some errors. Your queries are very interesting but i think that with the above ones i meet my requirements as the status field will be 0 for not processed rows and 1 for precessed ones (and the update will look for the row that meets the same 'where' clause than the select, and then, and only then, it will set status='1').
    The only thing i have to care about is what i questioned before.
    Thanks a lot and best regards,
    David

  • In setting up my ICal calendar I have specific times (as new events) that I want to be included in the print out.  This doesn't happen.

    In setting up my ICAL calendar I have specific times (as new events) for each day.  When it prints out the time does not show up (rather its a bar).  I would like the time for each appointment to print out. How do I do this?

    These are two possible approaches that will normally work to move an existing library to a new computer.
    Method 1
    Backup the library with this User Tip.
    Deauthorize the old computer if you no longer want to access protected content on it.
    Restore the backup to your new computer using the same tool used to back it up.
    Keep your backup up-to-date in future.
    Method 2
    Connect the two computers to the same network. Share your <User's Music> folder from the old computer and copy the entire iTunes library folder into the <User's Music> folder on the new one. Again, deauthorize the old computer if no longer required.
    Both methods should give the new computer a working clone of the library that was on the old one. As far as iTunes is concerned this is still the "home" library for your devices so you shouldn't have any issues with iTunes wanting to erase and reload.
    I'd recommend method 1 since it establishes an ongoing backup for your library.
    Note if you have failed to move contacts and calendar items across you should create one dummy entry of each in your new profile and iTunes should  merge the existing data from the device.
    If your media folder has been split out from the main iTunes folder you may need to do some preparatory work to make it easier to move. See make a split library portable.
    Should you be in the unfortunate position where you are no longer able to access your original library or a backup then then see Recover your iTunes library from your iPod or iOS device for advice on how to set up your devices with a new library with the maximum preservation of data.
    tt2

  • DB Back to a Specific Time with Archive Logs (Until cancel or time?)

    I'll try to be as clear as possible with my intended goals and the limitations of the system I'm working with:
    1. We have a test instance of our Oracle DB that I would like to be able to refresh with data from the production instance at any time, without having to shut down the production database or put tablespaces into hot backup mode.
    2. Both systems are HP Itanium boxes with differing numbers of CPUs and RAM. Those differences have been taken into account in the init.ora file for the DB instances.
    3. The test and production instances are using a SAN to hold the following file systems: ora_redo1, ora_redo2, ora_archlog, oradata10g. The test instance is using SAN snapshots (HP EVA series SAN) of the production file systems to pull the data over when needed. The problem is that the only window to do this is when the production system is down for nightly maintenance which is about a 20 minute period. I want to escape this limitation.
    What I've been doing is using the HP SAN to take snapshots of the file systems on the production system mentioned above. I do this while the production DB is up and running. I then import those snapshots into the test system, run an fsck to ensure file system integrity, then start up the Oracle instance as follows:
    startup mount
    Then I run the following query I found on line to determine the current redo log:
    select member from v$logfile lf , v$log l where l.status='CURRENT' and lf.group#=l.group#;
    Then I attempt to run a recovery as follows:
    recover database using backup controlfile until cancel;
    When prompted, I enter the path to the first of the current redo logs and hit enter. After waiting, sometimes it says that the recovery completed, other times it stops saying there was an error and that more files are needed to make the DB consistent.
    I took the above route because doing a recover until time (which is what I really want to do) kept prompting me for the next archive log in sequence that didn't yet exist when I took the SAN snapshot. Here was my recover until time command:
    recover database until time 'yyyy-mm-dd:hh:mm:ss' using backup controlfile;
    What I would like to do is take the SAN snapshot and then recover the database to about a minute before the snapshot using the archive logs. I don't want to use RMAN since that seems to be overkill for this purpose. A simple recovery to a specific point in time seems to be all that is needed and I have archive logs which, I assume, SHOULD help me get there. Even if I have to lose the last hour's worth of transactions I could live with that. But my tests setting the specific time of recovery to even 12 hours earlier still resulted in a prompt for the next, non-existent archivelog.
    I will also note that I even tried copying the next archive log over once it did exist and the recovery would then prompt me for the next archive log! I will admit right now that I really don't know a whole lot about Oracle or DBs, but it's my task to try and make it possible to "refresh" the test DB with the most recent data with no impact on the production DB.
    The reason I don't want to use hot backup mode is that I don't know the DB schema other than there are probably 58 or more tablespaces. The goal is to use SAN snapshots for their speed instead of having to take RMAN files and copy them to the test instance. I'm sure I'm not the only person who has ever tried this. But most of what I've found on line refers to RMAN, hot backup mode, or down time. The first two don't take advantage of SAN snapshots for a quick swap of all the Oracle file systems and I can't afford downtime other than that window at night. Is there some reason that the recover to time didn't work even though I have archive logs?
    One final point. The recover until cancel actually worked a couple of times, but it seems to be sporadic. It likely has something to do with what was happening on the production DB when I created the SAN snapshots. I actually thought I had a solution with recover until cancel last week until it didn't work three times in a row.

    I haven't completely discounted it but it seems like I would need to back up to files, then restore from files. I don't want to do that. I want a full file system level SAN snapshot that I can just drop into place. The does work when the production base is shut down. However, considering that I do have archive logs, shouldn't it be possible to use them to recover to a specific scene without having to do an RMAN backup at all? It seems that doing an RMAN backup/recovery would just make this whole process a lot longer since the DB is 160 gigs in size (not huge, but the dump would take more time than I would like). With a SAN snapshot, if I can get this to work, I'm looking at about a 15-20 minute period of time to move the production DB over to test.
    Since you are suggesting that RMAN may be a better approach I'll provide more details about what I'm trying to do. Essentially this is like trying to recover a DB from a server that had its power plug pulled. I was hoping that Oracle's automatic recovery would do the same thing it would do in that instance. But obviously that doesn't work. What I want to do is bring over all the datafiles, redo logs, and archive logs using the SAN snapshot. Then if possible use some aspect of Oracle (RMAN if it can do it) to mount the database, then recover to a specific time or SCN if using RMAN. However, when I tried using RMAN to do it, I got an error saying that it couldn't restore the data file because it already existed. Since I don't want to start from scratch and have RMAN rebuild files that I've already taken snapshots of (needless copying of data), I gave up on the RMAN approach. But, if you know of a way to use RMAN so that it can recover to a specific incarnation without needing to runm a backup first, I am completely open to trying it.

  • Split Rows and Store the selection

    Hi all,
    I have a table with a column where there is a numeric data and I developed a code that, if the user insert a number > 1 and he clicks on enter, he writes this row as many times as the number inserted.This table has not a ID that indentify the row, and if I select one or more rows and I click on Enter on numeric data I see that I lost my selection. I think because when I add new rows at my table, I make again the bind of the table, but... there is a method for to store my precedent selection (for ex. the rows that I don't want to split)?
    Tks a lot.

    hi,
    Use this code to get the index of row in which Enter is pressed.
    DATA: lv_index TYPE i.
    lo_el_cn_node = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).
    lv_index = lo_el_cn_node->get_index( ).
    Now you can store this index and later after you are done with binding of more rows to the table, Set the lead selection index to lv_index.
    lo_nd->set_lead_selection_index( lv_index ).
    I hope it would help.

Maybe you are looking for