Group by time interval

Hi all,
I'd like to group data by some time interval (lets say half hour), so i can't use: group by trunc(date,?) because i don't have a time format which can describe this level of group (unless oracle has upgraded this ability...maybe a feature request:)
is there a workaround to do that? any solution will be appreciated
Regards
Liron

Hi I don't know if this would be the most optimum approach but it got the job done for me.
I my case I had timestamps intead of date and I did the following.
Select (CASE
WHEN (cast(to_char(thetime, 'mi') as int) <= 30 ) THEN
(to_char(thetime, 'hh:') || '00' || to_char(thetime, ' PM') || ' - ' || to_char(thetime, 'hh:') || '30' || to_char(thetime, ' PM'))
ELSE
(to_char(thetime, 'hh:') || '30' || ' ' || to_char(thetime, ' PM') || ' - ' || to_char(thetime + interval '1' hour, 'hh:') || '00' || to_char(thetime, ' PM'))
END) ServiceTime, count(*) ServicedPeople
From
select (systimestamp + interval '15' minute) thetime from dual
UNION
select (systimestamp + interval '30' minute) thetime from dual
UNION
select (systimestamp + interval '45' minute) thetime from dual
UNION
select (systimestamp + interval '60' minute) thetime from dual
UNION
select (systimestamp + interval '75' minute) thetime from dual
UNION
select (systimestamp + interval '90' minute) thetime from dual
group by (CASE
WHEN (cast(to_char(thetime, 'mi') as int) <= 30 ) THEN
(to_char(thetime, 'hh:') || '00' || to_char(thetime, ' PM') || ' - ' || to_char(thetime, 'hh:') || '30' || to_char(thetime, ' PM'))
ELSE
(to_char(thetime, 'hh:') || '30' || ' ' || to_char(thetime, ' PM') || ' - ' || to_char(thetime + interval '1' hour, 'hh:') || '00' || to_char(thetime, ' PM'))
END)

Similar Messages

  • Dynamic Grouping on Time Interval Parameters

    I have started a report that pulls volumes from our database dependant upon an Interval parameter. This function works just fine using the following code.
    WHERE
    (@Interval = 'Daily (Yesterday)') AND (Date_DateTime >= DATEADD(dd, -1, DATEDIFF(dd, 0, GETDATE())) AND Date_DateTime < DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())))
    OR (@Interval = 'Weekly (Sun-Sat)') AND (Date_DateTime >= DATEADD(wk, DATEDIFF(wk, 7, GETDATE()), - 1) AND Date_DateTime <= dateadd(ms,- 3,dateadd(wk,datediff(wk,7,getdate()),6)))
    OR (@Interval = 'Weekly (Mon-Sun)') AND (Date_DateTime >= dateadd(wk,datediff(wk,7,getdate()),0) AND Date_DateTime <= dateadd(ms,- 3,dateadd(wk,datediff(wk,7,getdate()),7)))
    OR (@Interval = 'Weekly (Previous 7 days)') AND (Date_DateTime >= dateadd(day,datediff(day,0,GetDate())- 7,0) AND Date_DateTime <= dateadd(ms,- 3,dateadd(day,datediff(day,0,GetDate())- 0,0)))
    OR (@Interval = '4 previous weeks (Sun-Sat)') AND (Date_DateTime >= dateadd(wk,datediff(wk,7,getdate()),-22) AND Date_DateTime <= dateadd(ms,- 3,dateadd(wk,datediff(wk,7,getdate()),6)))
    OR (@Interval = 'Monthly (Last full Month)') AND (Date_DateTime >= dateadd(mm,-1,dateadd(mm,datediff(mm,0,getdate()),0)) AND Date_DateTime <= dateadd(ms,-3,dateadd(mm,0,dateadd(mm,datediff(mm,0,getdate()),0))))
    OR (@Interval = '3 Months (Last 3 full Months)') AND (Date_DateTime >= dateadd(mm,-3,dateadd(mm,datediff(mm,0,getdate()),0)) AND Date_DateTime <= dateadd(ms,-3,dateadd(mm,0,dateadd(mm,datediff(mm,0,getdate()),0))))
    OR (@Interval = '90 days (Current Date - 90)') AND (Date_DateTime >= DATEADD(dd, -90, DATEDIFF(dd, 0, GETDATE())) AND Date_DateTime <= DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())))
    OR (@Interval = 'Yearly (Last full Year)') AND (Date_DateTime >= dateadd(yy,-1,dateadd(yy,datediff(yy,0,getdate()),0)) AND Date_DateTime <= dateadd(ms,-3,dateadd(yy,0,dateadd(yy,datediff(yy,0,getdate()),0))))
    OR (@Interval = 'Yearly (Last 12 full Months)') AND (Date_DateTime >= dateadd(mm,-13,dateadd(mm,datediff(mm,0,getdate()),0)) AND Date_DateTime <= dateadd(ms,-3,dateadd(mm,0,dateadd(mm,datediff(mm,0,getdate()),0))))
    OR (@Interval = 'Custom (Select Start Date and End Date)') AND (Date_DateTime >= @StartDate AND Date_DateTime <= @EndDate)
    Now I would like to be able to have my graph dynamically change dependant upon which Interval is selected. So for example if Daily or any of the Weekly Intervals are selected, the graph will show a Daily bar with the appropriate Date. If any of the Monthly
    or Yearly intervals are selected, it will show a Monthly graph with appropriate date.
    I can get it to work one way or the other, but I would like for it to be dynamic.

    Hi D.Hansen,
    According to your description, you want your chart to display records based on parameter selection. Right?
    In this scenario, since your where clause in query is working fine, so it can already return the records dynamically based on Interval selection. Now we just need to put the Date_DateTime into Category in the chart, it supposed to display records dynamically.
    Based on your information, we still can't figure out what the issue is. Please post some detail information or screenshots of the report design if possible. It may help us test your case in our local environment. Thank you.
    Best Regards,
    Simon Hou

  • How to include Time Interval in crystal report

    Hi All,
           I have to create a  crystal report in  XI release 2. In the report I have 2 query side prompts "FromDate" and "ToDate" and one report side prompt "Time Interval". I have to show the data for each time interval between the two dates. means suppose if my "Fromdate" is 23 March 2010 and "Todate" is 25 march 2010 and time interval is 1 hour then I have to show data for each 1 hour time gap. means suppose my data in Db starts from 23 march 2010,11:25:25 then I must show data between 11:25:15 to 12:25:15 and so on...upto 25 march 2010.
         I am not able to retrieve the data accordingly. And how to use the timeinterval to retrieve data from db for that particular time interval.Please reply asap.
    Edited by: anushree2187 on May 21, 2010 7:28 AM
    Edited by: anushree2187 on May 21, 2010 7:37 AM

    you can create a group on the date field and then select how to group it by date, you can go up to the second.

  • Customer ##1 Enter a valid time interval error while generating customer BP

    Dear Experts,
    I am getting the following error when I am auto generating Customer while creating Business Partner in BP transaction code.
    Customer ##1: Enter a valid time interval
    Message no. CMD_API087
    Had anybody faced this problem?
    Regards
    Komal

    Hi,
    In Transaction 'BP', after values is put for BP name, Grouping & Create in BP role, there is a field for Validity period. Click on the icon to Create Validity period. This should resolve the issue.
    Regards,
    Nimesh

  • How to Group discontinued time periods

    Hi All:
    I have an issue which costs me bunch of time to develop. Basically I am trying to use discounted time in a select query but feel  like get nowhere to start.
    the scenarios is like this:
    I have many rows of data of this and I would like to have a solution I can select time period from just like what I can do for integer and text:
    Select *
    From Table
    Where Group = B
    and Open_Date in (select the all group A's time interval)
    to explain this problem in plain text, I would like to select all records from Group B whose Open_Date is within the interval between Group A's Open_Date and Close_Date. Thanks all in advance.
    Record
    Open_Date
    Close_Date
    GROUP
    1
    9/12/2013 9:25
    9/12/2013 10:44
    A
    2
    9/12/2013 10:19
    9/12/2013 10:39
    A
    3
    9/12/2013 10:22
    9/12/2013 10:22
    A
    4
    9/12/2013 10:56
    9/12/2013 12:41
    B
    5
    9/12/2013 12:00
    9/12/2013 12:00
    B
    6
    9/12/2013 12:00
    9/12/2013 12:01
    A
    7
    A+E301:H318
    9/12/2013 12:03
    A
    8
    9/12/2013 13:44
    9/12/2013 13:46
    C
    9
    9/12/2013 13:46
    9/12/2013 13:46
    C
    10
    9/12/2013 13:46
    9/12/2013 14:33
    C
    11
    9/12/2013 14:04
    9/12/2013 14:09
    A
    12
    9/12/2013 14:23
    9/12/2013 17:05
    A
    13
    9/12/2013 15:54
    9/12/2013 15:54
    A
    14
    9/12/2013 15:54
    9/12/2013 15:55
    B
    15
    9/12/2013 15:55
    9/12/2013 15:55
    B
    16
    9/12/2013 15:55
    9/12/2013 15:58
    A
    17
    9/12/2013 16:02
    9/12/2013 16:02
    A

    Sorry cannot test it right now
    Select *
    From Table
    Where Group = B
    AND Open_Date in (SELECT OpenDate FROM Table WHERE  Group = A
    AND  OpenDate  BETWEEN OpenDate  AND CloseDate )
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Time Interval for Daily Calendar in APEX 3

    Hi,
    we're looking at upgrading to Apex 3 and I have a question about the Daily Calendar time interval. Is there a way to change the interval to say, 15 minutes from the default 1 Hour?
    Cheers
    Kofi

    Hello Kofi,
    "Now looking at what I can see on apex.oracle.com, are you saying we'd just have to modify the daily calendar template?"The template only control the look of the calendar, not its functionality. If the default daily view meets your needs, you don't have to define any new templates.
    "I'd imagine that the whatever is creating the tags that will be displayed by the template needs changing to incorporate the other 15 minute cells I would add"Most of the calendar functionality you can control can be defined on the "Calendar Attributes" tab. The most important is the date column. If this column includes reference of time (on top of the date, of course) the APEX engine will automatically associate your entry with the proper "Hour" row. You are not adding cells. You are adding calendar entries. If several of these entries share the same hour slot, APEX will put all of then in the same row.
    The best way to understand it is simply define these entries. As I understand, you have access to apex.oracle.com, so it shouldn't be a problem.
    Regards,
    Arie.

  • Calendar time interval

    Hello,
    This is one of the questions asked in the forum by some one else too some time back.
    Using ADF 11g, By Default Calender component shows time interval of 1 hour. Can we configure it to show the time interval of 15 minutes.
    For example, default calendar shows
    1:00 AM
    2:00 AM
    3:00 AM
    But I would need something like
    1:00 AM
    1:15 AM
    1:30 AM
    1:45 AM
    2:00 AM
    Any input is greatly appreciated.
    Thanks....

    I am also in need of this feature, any inputs/suggestions are appreciated.

  • Reducing the time interval in file Adpt to write a flat file at a location

    Hi All,
    I hav a scenario where i hav to write a flat file (<b>XXX.txt</b>) to a location. b4 doing that, i hav to check whether <b>XXX.txt</b> already exists or not. If it doesn't exists then i hav to write the <b>XXX.txt</b> file there. if it already exists, then i hav to wait until that <b>xxx.txt</b> file gets deleted.
    In the receiver file adapter v hav an option <b>file construction mode = <u><i>create</i></u></b> which does the same thing. but the problem here is it is taking too long (<b>more than 5 min</b>) which is not at all acceptable in my case (it is ok <b>if it takes 1 min</b>).
    Is there any way to <b>reduce the time interval</b> using the same option?
    Or do we hav any <b>work around solution</b> for acheiving the same scenario?
    any help wud b appreciated.
    Thnx in Adv.
    Anil

    Anil
    As far as my knowledge goes I think it is not possible because we are not going to do anything from our end. XI is doing processing and creating a file for you. But you might be sending a large file at a time. So you have to improve the performance in your scenario. You check this urls on how to improve performance in XI:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/70ada5ef-0201-0010-1f8b-c935e444b0ad
    Improving performence in XI
    Maximum Permitted File Size in XI
    ---Satish

  • Fatch data from a table after a given time interval

    Hello
    I want to fetch date from a table after a fixed time interval is there any
    way to do it.
    thanks

    Not sure what you want. But maybe this helps.
    SELECT date+interval FROM atable;
    Also if you tell us more about the business case the answers could be more to the point.

  • How to take the data from excel list to sap r/3(with time interval)

    hi experts,
       how to transfer the data from a third party system(if it is in format of excel) to sap r/3.with that in a particular time interval,it will delete the data from excel sheet.

    Hi
    use the Fm
    'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                filename                = p_path
                i_begin_col             = '1'
                i_begin_row             = '2'
                i_end_col               = '2'
                i_end_row               = '500'
          giving the starting row and column and passing the ending row and column name
    Reward points if useful........
    Regards,
    Nitin Sachdeva

  • What is a fast way to drive a HP53132A counter to do real time, "time interval" measurements?

    Right now I run my system on a simple PCI GPIB bus. The fastest I can the time interval measurement is at 100 Hz. However, the has 350 ns timing and the PC running the program is much faster than this. So I should be able to achieve a rate of at least 10 kHz (depending on the counter of course). Do you have any suggestions for the way to set up the counter for the fastest measurement?

    I think that you're running into a limitation of the counter itself. My manual for the 53131 says that it can can do a maximum of 200 GPIB measurements per second. I think that the 53132 is similar except for extended resolution. What you might try is the STATS mode where you command the counter to take a number of measurements and then calculate the statistic. It is generally fster to let an instrument do a series of measurements and accumulate the results than to try and transfer one measurement at a time over the GPIB bus. VXI, PCI, PXI instruments can do things a lot faster so that might be an option as well. You should also be aware that your rate of 10 kHz requires timing resolution greater than what is in a PC (a PC has 1 msec resolution at best a
    nd it's not deterministic at all) so if you need something accurate, you'll have to use external hardware timing.

  • Time interval in Asset master record.

    Hi All,
    I am creating asset master record using AS01. Then I am doing intercompany transfer of asset via T Code ABT1N.
    If I view the asset time dependant data after this I am getting the following:
    1. The time interval mentioned is 01.01.1900 till 31.08.2007.
    2. When I add the furthur time interval I am getting the ABAP dump.
    Please help on this.

    Hi,
    When you look in the dump you see on the begin somwere of the dump
    > here you see the reason for the dump, perhaps there is field what can help you to solve the problem.
    You can have a look with the programmer and or create a message to SAP support.
    Paul

  • Invalid Time Interval error

    Hi Friends,
    I am loading HR data from Source. It loaded correctly without issues upto  PSA and when i trigger the DTP from the PSA to the IO 0EMPLOYEE,  I am getting the following error.
    "0EMPLOYEE : Data record 25 ('00001028 ') : Invalid time interval '['20070731'/'20070527'] '[from/to]     RSDMD     189".
    It shows about 7 entries in the error for employee 00001028.
    When i check the data in PSA the from and to Values are correct.
    Person           Start Date        End Date
    1028              01.10.2002      26.05.2007
                          27.05.2007      31.07.2007
                          01.08.2007      31.01.2008
                          01.02.2008      29.02.2008
                          01.03.2008      27.09.2008
                          28.09.2002      31..12.2008
                          01.01.2009      31.12.9999
    So, the from Data and to Date is correct yet I am getting the Invalid Time Interval error and my data load is failing.
    It is happening for a all the records.
    Can someone please tell me /suggets me how to resolve this issue?.
    Yore help is appreciated.
    Regards
    BN

    Hi,
    Please check the note:
    310304 -> DATETO/DATEFROM:Extracting time-dependent master
    http://help.sap.
    com/saphelp_nw70/helpdata/en/13/c3e7379899d06fe10000009b38f8cf/frameset.
    htm
    It should resolved your issue.
    Thanks,
    Venkat

  • Read no. of pulse count with fixed time interval

    Hi,
    I am try to read no of pulse count ( Pulse period = 500ms, On time = 100msec and Off time = 400msec). Between pulses there is a fixed time interval of 2seconds. I am using NI USB DAQ 6341. Can anybody help me regarding this? 

    Thanks for replying. I have gone through  that example, the given example are only increment count when pulese are detected.
    In my case, i want to count the no. of pulses between the time interval of 2sec. e.g. Suppose my device generate 5 no. of pulses and after every 5 pulses their is 2sec time interval, here i need to read only 5 pulses not the continuous count. And no. of pulses are generated by device can be vary but the time interval between those pulses are fixed. Could you give me suggession regarding this?

  • How to change color of a button for specific time interval in jsp

    How to change color of a button for specific time interval in jsp.
    Please help.
    Thanks in advance.

    This was driving me crazy, too--and the previous answers did not seem to work. I eventually found that if I click one of the data symbols in the graph in exactly the right spot (see below), it selects only the data symbols and not the line. I can tell this because the little selection dots will be around each data symbol, but no selection dots will be on the line between the data symbols - like the graphic in Yvan's answer. Then and only then will the color symbol in the tool bar show the color of the data symbol, instead of the color of the line. I believe that you then have to first click on the color swatch in the toolbar and then select your color (or choose Show Colors and select from the color tool). Just clicking a color in the crayon box, for example, did not seem to work unless I first clicked on the color swatch in the toolbar, then clicked Show Colors on that dropdown, and +only then+ clicked the crayon or whatever.
    _The right spot to click_ seems to be just above the exact center of the data symbol, at least for the diamond shape symbol that I prefer. Sometimes it takes several tries to hit the right spot. If I miss it, the whole line is selected, which is indicated by the little selection dots on the line, between the data symbols. When I click the right spot, those selection dots go away, leaving only the data symbols selected. Then I can change the color, as described above.
    I hope this works for you too.

Maybe you are looking for

  • Report based on dynamic query

    I have done the same way as shown in the 'How To document'. But it does not work. It just ignores what is mentioned inside the if-end if construct. I have used the sample application itself and followed exactly what is mentioned in the article.The ou

  • Java and daylight savings time

    I just tricked my OS into thinking it is DST but setting the date ahead a bit. After checking, my OS DOES think it is currently DST (with a date of April 3). However, Java doesn't seem to get it! For example, take the following two lines of code:    

  • Why firefox keep deleting my history? i try to reinstall it but it won't work. help me please.

    I just upgrade my windows and reinstall my firefox. then it won't make me save my history. at first the history saved. but when I restart my laptop then open my firefox the history won't show up. and i try to reinstall but nothing changes. help :(

  • Raising a long error message

    I need to raise the following error message.Following one is the message to be raised “Error:  Combination of Document Currency [bkpf-waers], Local Currency [t001-waers], Group Currency [t000-mwaer] not allowed for transaction [bkpf-tcode].  Identica

  • To find timestamp of Exchange 2010 Online Archive Execution Status

    Hi, I would like to have Exchange online archive execution timestamp whenever it's running through managed retention policies. Can anyone help to provide the script or way to find the last online archive completion status for individual mailbox level