Group By date time columns

I am trying to write a sql statement that will group datetime column in a result set by the number of days. Based on an input value I need to sum a number column where the data is grouped every x number of days. One run the result set may be calculated for data within every 5 day period the next run may be a 15 day period. How would you write a group by statement to accomplish this?

select to_date(trunc(to_char(d,'J')/5)*5,'J'), sum...
from...
group by to_date(trunc(to_char(d,'J')/5)*5,'J')

Similar Messages

  • Type of object from a database date/time column

    Hello everyone,
    I've got a concern regarding the way in which coldfusion is
    treating date/time columns in a database.
    In my opinion when I select a column that is let's say
    timestamp type - the object in a query is CF's date/time object.
    I've checked the query by getMetaData() and it looks like each
    column has its own database type (eq. varchar2, date, etc).
    My concern comes from a fact that I've heard that Coldfusion
    is treating the date-time columns in a database as strings and in
    each case it parses them. So the difference in a locale between a
    database server and a Coldfusion server may result in a wrong
    date/time object.
    Example:
    Locale of database EU: yyyy/mm/dd
    Locale of Coldfusion US: yyyy/dd/mm
    The date like 1st of February 2007 stored in a database would
    look then in Coldfusion like: 2nd of January 2007
    Could someone please confirm which version is valid?

    Johnny852 wrote:
    > In my opinion when I select a column that is let's say
    timestamp type - the
    > object in a query is CF's date/time object. I've checked
    the query by
    > getMetaData() and it looks like each column has its own
    database type (eq.
    > varchar2, date, etc).
    if you already know cf is returning a datetime from a
    datetime in the db, what's
    the question?
    > My concern comes from a fact that I've heard that
    Coldfusion is treating the
    "fact"? unless the datetime is stored as a string, that's not
    a "fact".
    > Example:
    > Locale of database EU: yyyy/mm/dd
    > Locale of Coldfusion US: yyyy/dd/mm
    btw neither of your example "locales" are in fact locales.
    > The date like 1st of February 2007 stored in a database
    would look then in
    > Coldfusion like: 2nd of January 2007
    if you pass a numeric string representation (2/1/2007 for
    instance) of a date to
    cf, it will be interpreted via the cf server's "default"
    local (ie en_US,
    month/day/year) unless you use one of the LS functions like
    LSParseDateTime() &
    specifically set the the locale (like setLocale("th_TH")) or
    make the date
    non-ambiguous (2-feb-2007) or build the date yourself from
    user input using
    createDate() or createDateTime(). you just need to convert
    the user's string
    representation to a valid cf datetime object (or i guess
    force to database to
    follow the user's locale date mask).

  • Adding 18 hrs to a Date/Time column

    Hi All 
    Power Query provides the functionality to add days to a Date/Time  column with the  " Date.AddDays()"  function. However this appears to only accept whole numbers as inputs.
    I want to add 18 hrs to a Date/Time column  How can I do this?
    Cheers
    Steve

    I was able to achieve this by converting the date into a number, adding 0.75 and then converting back into a date.
    Here is the code, source is just a workbook with the following data
    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        AddC= Table.AddColumn(Source, "Time", each Number.From([DateTime])),
        ValueAdd = Table.AddColumn(AddC, "Custom", each [Time] + 0.75),
        HoursAdded = Table.AddColumn(ValueAdd, "Time +18", each DateTime.From([Custom]))
    in
       HoursAdded
    Final Output
    Would be interested if there is a more elegant alternative

  • Displaying 'Date & Time' Column

    Hi there, I did do some searching/ reading prior to posting this, but haven't found what I'm looking for...
    I want to copy/ paste all my texts from my Nokia 6288 to my pc...
    -this works no hassle, I simply use the Nokia Phone Browser to load all my 'Inbox' and 'Sent Items' and move them to the desired folder on my hard drive...
    Problem is, in the Nokia Phone Browser, I get columns I can't seem to get in either Windows XP Pro or Windows Vista Business (which has more columns on offer)...
    This means, when im looking at the files on my PC, rather than using the nokia phone browser, i dont get the same details which is a bit of a problem for me...
    So what I want to know is:
    How do i get the Date & Time Column (and all the columns the Nokia Phone Browser displays) to show up in Windows XP or Vista or both?
    Thanks in advance

    Hi Austin,
    I have two remarks about that.
    1) It's better to put the population of change/history attributes into a table trigger of type before row where you assign these values. eg.:
    :NEW.CREATE_DATE := SYSDATE;
    :NEW.CREATE_USER := NVL(V('APP_USER'), USER);The reason is, it will consistently work for all applications which try to insert a record into this table and don't have to worry about change attributes and second, when you use the default property of APEX it will populate the column with the value when the new row was displayed and not when it was saved and third, a user would be able to fake this value and write something else into it (eg. with Firebug or by saving the HTML page) and "create" the record with a different time as you would expect. -> Define the column as "display only doesn't save state"
    2) Don't rely on automatic type conversion, remember that for APEX everything is a string that also means that your default value expression has to return a string to be 100% sure that it work on all systems where the default database format mask of Oracle could be different. Change your code to
    TO_DATE(SYSDATE, 'DD-MON-YYYY HH24:MI')Just some thoughts, but a testcase on apex.oracle.com is always good to reproduce and help with such a problem.
    Patrick
    My APEX Blog: http://www.inside-oracle-apex.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://apexplugin.sourceforge.net/ New!

  • Pre-populating a date/time column with the value entered in the last added item

    I have a list with a column called "expected finish date". Whenever the user adds the very first item in a list, he/she should have to enter a value for this column.
    I want to make all new item entries to pre-poplate this field with the value entered in the previously added item. This way, he/she wont have to re-enter the date every time (which rarely changes). How can this be done?

    could create a second list ("state") with column ("default finish date")...
    create a workflow on main list... if column is blank/empty, pull from second list... otherwise, update second list with the value that was entered.
    Or, customize the form (InfoPath or JavaScript)
    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com
    Strategic Data Systems - for all your SharePoint needs

  • Date / Time Column Display

    I want to be able to display within a JClient panel two separate fields - one a date and one a time, but I want both of these to reference a single database column, extracting the relevant portion of the data for display to the user.
    I have tried manipulating the entity but am coming across one or two problems when trying to update.
    Has anybody managed to achieve this kind of functionality within the BC4J/JClient framework ?
    Thanks.

    You may create two transient attributes on the entity which 'get their data' from the actual-persistent column and return just the date or just the time portions. On set of any of these transient-attributes, you should also update the persistent-attribute value with the approrpriate value.
    Then map these transient attributes on the VO and then on the JClient form to say two textfields.
    If you're encountering some specific problem/exception doing this, you may want to expand on your example/usage and the behavior seen so that we can simulate the scenario to provide further suggestions.

  • How to remove time zone from date time column?

    Hello all,
    I have one birthday calendar list where I am showing birthdays of employees in acompany.
    Now when I display Date in a page I am getting the below output:
    Fri Sep 19 2014 00:00:00 GMT-0700 (Pacific Standard Time)
    Here I just want the below thing as an output:
    Fri Sep 19 2014
    the other things like 00:00:00 GMT-0700 (Pacific Standard Time)
    How should I achieve it?
    Thanks in Advance.

    Hi
    you should use XSLT datetime formatting
    http://amavs.wordpress.com/tag/formatdatetime/
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • How to combine date column and time column?

    Hello all,
    The question is pretty much as it says. I have two columns of data, one is in format 8/28/2014 and the other is in format 10:00 PM.  Both are formatted as text because I got frustrated with numbers forcing me to only format things as Date AND Time.  I want to be able to sort the list in chronological order, and I can't sub-sort columns. So, how can I combine them into one date+time column so that I can sort?
    Thanks!
    -acousticguitar7

    AG,
    If your Date is in A and your Time is in B, the formula to combine them would be:
    =A+TIMEVALUE(B)
    Jerry

  • How can i select some row from multiple row in the same group of data

    I want to select some row from multiple row in the same group of data.
    ColumnA        
    Column B
    1                  OK
    1                   NG
    2                   NG
    2                          NG
    3                          OK
    3                          OK
    I want the row of group of
    ColumnA if  ColumnB contain even 'NG'
    row , select only one row which  Column B = 'NG'
    the result i want = 
    ColumnA         Column B
    1                         NG
    2                   NG
    3                          OK
    Thank you

    That's some awful explanation, but I think this is what you were driving at:
    DECLARE @forumTable TABLE (a INT, b CHAR(2))
    INSERT INTO @forumTable (a, b)
    VALUES
    (1, 'OK'),(1, 'NG'),
    (2, 'NG'),(2, 'NG'),
    (3, 'OK'),(3, 'OK')
    SELECT f.a, MIN(COALESCE(f2.b,f.b)) AS b
    FROM @forumTable f
    LEFT OUTER JOIN @forumTable f2
    ON f.a = f2.a
    AND f.b <> f2.b
    GROUP BY f.a

  • Output triggred in the invoice with Date/Time 1

    Output triggred in the invoice with Date/Time as 1 i e Send with periodically scheduled job.
    So could you  let me know when this gets triggeed if we maintain 1 in condition record?
    Thanks,
    Praveen

    Hi Praveen,
    When you maintain 1in the Date/Time column in the Condition Records for O/P of say the Invoice it means that you are telling the system to send the O/P with periodically scheduled job.
    To achieve this you must use the report program RSNAST00.The message is processed through report program RSNAST00. This report program can be scheduled periodically or started manually.
    For scheduling periodically you need to set up a batch process in SM35.
    Hope this helps,
    J Nagesh

  • Maintain Date/Time Stamp in Export as XML

    Hello,
    I've create a report which has a field as mm/dd/yyyy HH:mm.
    When I export as .TXT .CSV, Excel ect it maintains the format; however when I export as XML I loose the formate and it exports as mm/dd/yyyy 12:00:00
    The below in anyother format or in BusinessObjects would be 09/04/2007  10:38.
    <COLUMN INDEX="6" ID="4" TYPE="Date" FORMAT="m/d/yyyy  hh:mm:ss  AM/PM">Actual Start (Date & Time)</COLUMN>
    <CELL INDEX="6">9/4/2007 12:00:00 AM</CELL>
    Any thoughts?
    As well is it possible to customize tags of the exported XML so it is more of a XML document then a spreadsheet.

    Thank you!
    For the issue with the Date/Time stamp is this a bug in older versions? I am using BusinessObjects 6.1; the only time it does this is when exported as XML
    Cheers,
    Tim
    Edited by: Tim Whitehead on Jul 13, 2008 7:17 PM

  • Problem in taking the average of a column and grouping by date

    Hi all,
    I created a logical column using a formula in "Administration". The formula is like;
    Duration%=(Duration*100)/(X-Y).
    Then, in "answers", I created a report using Duration% column and another column which is its average. I want to see the average of Duration% values grouped by date.
    The numbers in the report are incorrect. What can be the reason for this? Does using logical column which is derived with a formula cause a problem when we take its average?
    Thanks in advance for your help..

    use avg(Duration% by <"Date Table"."Date Level"> in the answers column.
    substitute "Date Table" with your actual time dimension table name, and "Date Level" with your actual date column that you want to group by.

  • How to delete the date and time column from a waveform spreasheet file

    after acquiring a signal through the DAQ i am writing it in a spreadsheet. but for further post processing of the data the date and the time column are unneccessary. is there some way to format the file in labview so that those columns are removed. the DAQmx read  gives as output a 1 d array. so i could not find a way to select only the Y column

    If you are getting a 1D array from the DAQmx Read, then you don't have any date/time information to write and if you are using the Write to Spreadsheet File, there should be no way you can have the date/time information in the file. Whatever you hjave programed to put the date/time into the file, don't do it.
    p.s. You may not think you need timing information but for a lot of post-processing, it is essential to have. If it's in the file, you can always ignore when you read it and if you later find out it's necessary, it will already be there.

  • From Time column in Excel to Java Date ?

    Hi there!
    After I have read range data from Excel to a Java Object[][]
    array/table, one of my excel time columns becomes "floats"
    numbers when I try to access them in Java, like this:
    from 15:00:00 in Excel to 0.625 in my Java program
    How can I avoid this OR transform/parse this 0.625 number
    back again to time/Date 15:00:00 inside Java ? hmmm
    Is there any setup of jCom that can controll this somehow ?
    I have been able to transform:
    from 11.15.01 in Excel, becomes "Thu Nov 15 00:00:00 CET 2001"
    with the jCom bridge ...
    When I have this "string" on this format, it's easy
    to get a Java Date of this with SimpleDateFormat.
    ... but not with this time of mine :-)
    Any clues where to look or a solution for this ?
    -- Thank you !
    -- Erlend

    Excel stores times as decimal fractions (representing portions of a day)
    There is no Time data type in VB so is probably represented by a Single
    object.
    This object is then converting to a java.lang.float on the Java side.
    0.625 can be parsed by multiplying by (24*60*60) to get the number
    of seconds after midnight.
    A list of supported COM data types and their java equivalents
    can be found in chapter 7 of the jCOMReference pdf file.
    damon
    "Erlend Bjorge" <[email protected]> wrote in message
    news:3be2983e$[email protected]..
    >
    Hi there!
    After I have read range data from Excel to a Java Object[][]
    array/table, one of my excel time columns becomes "floats"
    numbers when I try to access them in Java, like this:
    from 15:00:00 in Excel to 0.625 in my Java program
    How can I avoid this OR transform/parse this 0.625 number
    back again to time/Date 15:00:00 inside Java ? hmmm
    Is there any setup of jCom that can controll this somehow ?
    I have been able to transform:
    from 11.15.01 in Excel, becomes "Thu Nov 15 00:00:00 CET 2001"
    with the jCom bridge ...
    When I have this "string" on this format, it's easy
    to get a Java Date of this with SimpleDateFormat.
    ... but not with this time of mine :-)
    Any clues where to look or a solution for this ?
    -- Thank you !
    -- Erlend

  • Auto populating the Date/Time Field in a Column

    I'm having an issue with the a Date and Time Column type auto populating the current date and time correctly.  I've put the =Now() function in the calculated value box.  I get the correct date and I get a time but the time is wrong,  its
    on Pacific Time and my regional settings on the site are Central Time.  I can't find any way to specify use central time.  is this a bug on microsoft's end or mine?  It was working yesterday and not today.

    check what time zone is your central admin is set to 
    using 
    http://<CentralAdminUrl>/_layouts/regionalsetng.aspxand if its pointing to pst you will get pst result .you will see the options wil time zone selected and also some other like calender etc
    if you want to change reginaol time for your site so to site settings ==> under site adminstration 
    you will see regional settings where you can set the time zone it will look like this :

Maybe you are looking for

  • I could not able to see Imported Business Package

    Hi I am using Standard Business Package for SAP CRM4.0 60.2.3; it is stored in PCD -> Migrated Content I customized the Business Package and stored the content in my folder and transported the Business Package to Local (on Desktop) and Server (in ser

  • The Japanese file name is not displayed.

    I'm using Mac OS 10.5.3(intel)/Adobe Media Player 1.0 In "Personal Videos",The Japanese file name is not displayed. Example, "日本語.flv" is added, ".flv" is displayed in "Personal Videos".

  • Why does my function not return anything when I create as a schema object

    I have user ABC who owns several tables some of which have foreign key constraints. I have user XYZ that has been granted access to all tables owned by user ABC. When I create a function as user XYZ using following I get no return when I issue: selec

  • GL History upload error

    Hello ABAP guys, For my client we are trying to test GL history upload thro LSMW, when i try to post to revenue acc 410000 with Profit Center # putting, system is asking for "Account 410000 requires an assignment to a CO object" I know that acc 41000

  • MacBook 2,1 upgrading to 10.6.*

    I have upgraded to 3GB ram and have 95GB disk space free. I am happy with my OS but I just have to have the latest and greatest, short of buying a new mac How much of a risk is this, what other prep should I make on my old book? I cant afford a backu