Average calculations with dates

Hi,
I have a problem with calculating the average time a call lasts. I have a start and finish time to a call that are stored in a database in datetime format. How do i find out the time of the call and then get an average over the number of calls made in a month. I have to hold the time format and show the result in the same time format that is in the database. How do you do this? I know how to do it with decimals but how to manipulate time confuses me.
Cheers
Niall

You can use the method getTime() of the class java.sql.Timestamp, which returns milliseconds in the long type, and toString() method of java.sql.Time may serve your aim here.

Similar Messages

  • How can I activate the average calculation with cl_salv_hierseq_table class

    Hi there,
    Iu2019m using class cl_salv_hierseq_table to display a two level hierarchy (header and item) list.
    For some reason it seams that those calculations are active by default with class cl_salv_table but not for cl_salv_hierseq_table.
    I tried every suggestion from the class documentation and SAP help and nothing seams to work, the menu calculation options are always inactive except for the total calculation.
    After the cl_salv_hierseq_table=>factory...
    And before cl_salv_hierseq_table->display( )
    I triedu2026u2026.
    cl_salv_aggregations = cl_salv_hierseq_table->get_aggregations( 1 )
    cl_salv_aggregations->add_aggregation( 'COLUMN1' )
    COLUMN1 is a currency column in header level table
    u2026u2026..
    cl_salv_aggregations = cl_salv_hierseq_table->get_aggregations( 2 )
    cl_salv_aggregations->add_aggregation( 'COLUMN2' )
    COLUMN2 is a dec column in item level table
    u2026u2026..
    cl_salv_aggregations = cl_salv_hierseq_table->get_aggregations( 2 )
    cl_salv_aggregations->add_aggregation( columnname = 'COLUMN2' aggregation = if_salv_c_aggregation=>average )
    u2026u2026..
    cl_salv_aggregations = cl_salv_hierseq_table->get_aggregations( 2 )
    cl_salv_aggregations->set_aggregation_allowed( 'COLUMN2' )
    u2026u2026..
    cl_salv_aggregations = cl_salv_hierseq_table->get_aggregations( 2 )
    cl_salv_aggregations->set_numerical_aggregation( ).
    cl_salv_aggregations->set_aggregation_allowed( 'COLUMN2' )
    cl_salv_aggregations->add_aggregation( columnname = 'COLUMN2' aggregation = if_salv_c_aggregation=>average )
    u2026u2026..
    cl_salv_aggregations = cl_salv_hierseq_table->get_aggregations( 2 )
    cl_salv_aggregations->add_aggregation( 'COLUMN2' )
    cl_salv_aggregation = cl_salv_aggregations->get_aggregation( 'COLUMN2' )
    cl_salv_aggregation->set( if_salv_c_aggregation=>average )
    Any help will be appreciated!

    Thanks Harsh Bhalla,
    Subtotals can be built (displayed) at Header Level Only, true but the values to calculate those totals can come from either header or item level, otherwise it wouldnu2019t be of much use would it?
    Anyway my question is how to activate the average calculation as well because the totals calculations is already active for either item or header level by default.
    For reference when on the display layout Iu2019m referring to the menu Edit -> Calculate -> Mean Value.

  • Average calculation with joins

    Hi all,
    Please have a look here.,
    Re: average calculation using sql
    My Question is :
    Is it possible to do a join here,
    so that in where condition thistable.id=newtable.id
    and in column area i need projects from new table.
    i.e.,
    Projects Name Remark SUM AVG
    I tried with this query..
    SELECT Projects,Name,Remark, SUM(work_hrs), AVG(work_hrs) FROM (
    SELECT name,remark ,a.id,b.id,start_dt,end_dt,SUM(end_dt-start_dt) OVER (PARTITI
    N BY name,remark ORDER by Name) work_hrs
    FROM T a,T1 b) where a.id=b.id
    GROUP BY ROLLUP(name,remark);
    But o/p is not as i expect..
    Thanks in advance...

    The alias 'b' does not exist outside of the subquery/inine view. Try to alias your subquery for clarity then refer to it;
    SELECT MAX(sub.sr_pm_name), sub.ts_desc, sub.ts_remarks, AVG(sub.work_hrs)
    FROM (SELECT ts_desc,
                 ts_remarks,
                 b.sr_id,
                 a.ts_srid,
                 b.sr_pm_name,
                 ts_expected_date,
                 ts_actual_date,
                 SUM(ts_actual_date - ts_expected_date) over(PARTITION BY ts_desc, ts_remarks ORDER BY ts_desc) work_hrs
          FROM t_status_report b, t_task_status a
          WHERE b.sr_id = a.ts_srid) sub
    GROUP BY ROLLUP(ts_desc,
                    ts_remarks);Another way that might be easier to follow is to use the WITH clause;
    WITH sub AS (
       SELECT ts_desc,
              ts_remarks,
              b.sr_id,
              a.ts_srid,
              b.sr_pm_name,
              ts_expected_date,
              ts_actual_date,
              SUM(ts_actual_date - ts_expected_date) over(PARTITION BY ts_desc, ts_remarks ORDER BY ts_desc) work_hrs
       FROM t_status_report b, t_task_status a
       WHERE b.sr_id = a.ts_srid)
    SELECT MAX(sr_pm_name), ts_desc, ts_remarks, AVG(work_hrs)
    FROM sub
    GROUP BY ROLLUP(ts_desc,
                    ts_remarks);

  • Formula variable for date calculations with date-characteristics (2004s)

    Hi SDN,
    I'd like to calculate the number of days between to date-characteristics. In 3.5, I was used to create 2 formula variables of the type 'replacement path', with 'date' as the dimension indicator. In my formula, I used the 'proces value as date' function for each variable, and I could perform calculations with them.
    I'm trying to do the same in 2004s. However, I can't create replacement path's with 'date' as a dimension indicator. So I use 'number' instead, but it doesn't work: my query shows 'x'.
    I can use the variables that I created using the 3.5 query designer as a workaround. But I hope there is a better solution.
    If other people experience the same problem, please respond. Then I know it's probably a bug.
    Kind regards,
    Daniel

    Daniel,
    Try to look at the formula variables defined before the upgrade and see what is different to the newly defined. I am guessing just the terminology used is different.
    If not the date value might be blank or something for one of the f-variables used. Try to display the formula variable values as KF in the query results and check what it is showing.
    I hope this helps.
    -Bala

  • Calculations with date fields

    I'm trying to do a basic calculation with a CRM date form in BC.
    I have a form field 'dateJoined' (though this could easily be the standard DOB field for the sake of this exercies) and I need to use javascript to calculate how many days have passed between today's date and the date in 'dateJoined'.
    The {module_customerfield} outputs a string, not a date object, which would be fine but the format of the string is not compatible with the .date object.
    I started down the path of lengthy substrings > variables, then linked variables > date object but after lines and lines of code, wondered if there was a simpler way that I was overlooking??

    I'm trying to do a basic calculation with a CRM date form in BC.
    I have a form field 'dateJoined' (though this could easily be the standard DOB field for the sake of this exercies) and I need to use javascript to calculate how many days have passed between today's date and the date in 'dateJoined'.
    The {module_customerfield} outputs a string, not a date object, which would be fine but the format of the string is not compatible with the .date object.
    I started down the path of lengthy substrings > variables, then linked variables > date object but after lines and lines of code, wondered if there was a simpler way that I was overlooking??

  • Calculation with Dates

    I have one date called Registration Date which will be input into the planning as string in dd--mm-yyyy format. Now I am capturing current date which should pickup from system(By @Today Function).
    I know that these dates are now in different formats. I need to calculate difference between these two dates.. I have tried many ways using datediff functions etc. But its not working. please Help me out on this

    Hi
    Try using @HspDateDiff
    You will need to convert the current date into the planning version of the date. You can do this with this formula
    (@DATEPART(@TODAY(),DP_YEAR)*10000) + (@DATEPART(@TODAY(),DP_MONTH)*100) + (@DATEPART(@TODAY(),DP_DAY));
    This will take the current date and put it into the YYYYMMDD format.
    You can then use @HspDateDiff(NewCurrentDate,RegistrationDate);
    You can use this link to help you with the use of @HspDateDiff Calculating the difference between dates within Hyperion Planning - Absolute EPM
    In later versions of Hyperion Planning there are many more functions for Dates within Calculation Manager
    Hope that helps.
    Anthony
    Home - Absolute EPM

  • Averaging column with date/time format in BI Answer

    Hi everyone
    we are working on BI answer and training to get the average of the working hours of the departments. The Working Hrs column is Date format in the Database so we tried to converted to CHAR through Cast Function from Edit columns Formula in Answers BI, and this gave us date "2007/09/01" as result!! We also tried to cast the Working hours to:
    CAST(WORKING HOURS AS CHARACTER FORMAT 'yyyyMMdd-HHmmss')
    NOTE: In the Working Hours we have null values...
    the actual working hours appear in Answer Table is "7/1/2009 6:13:00 AM"
    How to get the Working Hours column Average on Answer BI?
    Appreciate your help
    Regards
    Edited by: user817525 on Jul 21, 2009 11:15 PM

    how about next solution:
    60 * EXTRACT( HOUR FROM ATTENDANCES.A_ATT_TIME) + EXTRACT( MINUTE FROM ATTENDANCES.A_ATT_TIME)
    with this u have minutes for working day. If u divide this expression with 60:
    (60 * EXTRACT( HOUR FROM ATTENDANCES.A_ATT_TIME) + EXTRACT( MINUTE FROM ATTENDANCES.A_ATT_TIME)) / 60
    u now have hour with decimal (for 8:52 is (8*60+52)/60 = 8,67 )
    and u only need to round this number.I hope this help
    ps.when u have new question probably is good way to create new thread
    all best
    Phenix
    Edited by: Phenix on Aug 5, 2009 8:01 AM

  • Calculations with dates

    Hi,
    We need to do some calculations based on the dates. But as essbase doesnt store dates we are having a problem. Can anybody suggest a solution for this.

    You would store the dates as numbers in Essbase. It's pretty common in a Capex or Workforce application.
    Presuming you are using monthly dates Jan 2007 would be 200701 and December would be 200712 etc.
    You can use math and functions such as @TRUNCATE, @INT, and @MOD functions to determine the number of months between dates.
    If you are looking to store dates and do daily calculations that will of course be more complex.
    Here is a sample of some code I have sitting around:
    start_year = start_date - @INT(start_date / 100) * 100; /* gives 200700 from 200701 */
    start_months = start_date - start_year; /* gives 1 */
    add_years = @INT((start_months + num_months) / 12) * 100; /* determine number of years to add */
    add_months = @MOD(start_months + num_months,12);
    end_date = start_year + add_Years + add_months;
    Basically it's all math.
    Regards,
    -John

  • *Urgent* Query with dates

    Hi Gurus,
    I am having problem in developing such a query which has calculations with dates. The problem is:
    I have
    base date for example 26-feb-2006
    statring day: 4
    interval: 5
    input date: 15-mar-2006
    Now the problem is I want to get the results from the query which will start 26-feb-2006+4 which is 02-mar-2006 and calculate the interval which is 5 days from '02-mar-2006' and run it every 5 (interval) days
    02-mar-2006
    07-mar-2006
    12-mar-2006
    I hope I have cleared everything.
    Please let me know as soon as possible.
    Thanks in advance.
    Aqil

    Where is the base_date coming from?
    declare
    v_jobno number;
    dbms_job.submit(v_jobno, 'SCHEMA_NAME.sp_my_proc();',
    -- first time running I schedule for 11 pm staring in 4 days
                              trunc(sysdate+4)+23/24,
    -- here the interval
                              'trunc(sysdate+5)+23/24' );
    end;

  • Dealing with dates

    This is more an ActionScript 3 issue, but... is there any
    good library that allows to do calculations with dates? Like dateB
    = dateA + 1 month (taking into account that dateA could be a
    december day and then a year should be added and the next month is
    january, etc...).
    thanks in advance,
    Marc

    From what i've seen online in examples is to convert the date
    into it's numeric representation. That representation is in
    milliseconds past a low date, something like jan 1. 1901, but i
    don't remember. Then add or subtract milliseconds from the value.
    Then take the result and create a new date object.
    I have not needed to do this yet, so if anyone has a better
    solution that would be awesome.

  • How can I get max, min & average (hours with minutes) of fast 30 days data

    Table name:
    run_log
    TYPE VARCHAR2(10),
    SUBTYPE VARCHAR2(10),
    PROGRAM VARCHAR2(100),
    STATUS VARCHAR2(20),
    START_TIME      DATE,
    END_TIME      DATE
    How can I get max, min & average (hours with minutes) of fast 30 days data ?

    Hi,
    you have to use analytical functions:
    SELECT start_day,
           round(AVG(daily_avg)
                 over(ORDER BY start_day ASC RANGE BETWEEN INTERVAL '30' DAY preceding AND INTERVAL '0' DAY following)) AS moving_avg,
           round(MAX(daily_max)
                 over(ORDER BY start_day ASC RANGE BETWEEN INTERVAL '30' DAY preceding AND INTERVAL '0' DAY following)) AS moving_max,
           round(MIN(daily_min)
                 over(ORDER BY start_day ASC RANGE BETWEEN INTERVAL '30' DAY preceding AND INTERVAL '0' DAY following)) AS moving_min
      FROM (SELECT trunc(t.start_time) start_day,
                   AVG((t.end_time - t.start_time) * 24 * 60 * 60) AS daily_avg,
                   MAX((t.end_time - t.start_time) * 24 * 60 * 60) AS daily_max,
                   MIN((t.end_time - t.start_time) * 24 * 60 * 60) AS daily_min
              FROM run_log
             GROUP BY trunc(t.start_time)) t
    ORDER BY 1 DESCAnalytical functions are described in the Oracle doc "Data Warehousing Guide".
    Regards,
    Carsten.

  • Sales Order : Calcul delivery date with only working days

    HI,
    When I create sale order, the delivery date is calculed with the number of days mentionned in type of sale document. SAP add this number of days into the day's date.
    Is it possible to calculate this delivery date only with working days in the corporate calendar ???
    Thank's

    HI
    Delivery date in the Sales order will be calculated the calender only basedon the Transportation lead time and Pick/Pack time and excluding the holidays
    Please cross the same in your instance
    Regards,
    Ram.

  • Problem with date calculation

    I am a rookie in SAP i have a small problem with date.Do we have any function module to find out the first day in a month if we give out the system current date ?? Pls help me out.

    Hi,
    As Ganesan told,you can do.
    Here is the sample code.
    data v type sy-datum.
    data d type DTRESR-WEEKDAY.
    v+6(2) = '01'.
    v4(2) = sy-datum4(2).
    v0(4) = sy-datum0(4).
    CALL FUNCTION 'DATE_TO_DAY'
      EXPORTING
        date          = v
    IMPORTING
       WEEKDAY       = d.
    write d.

  • Add average calculation to FBL5N?

    Hi,
    My user requires an average calculation on one of the columns in FBL5N (customer line items).  This is a standard transaction which uses an ALV.
    I know that I can add new fields into this transaction using customizing but I need an average, so would need to create a new field and populate it with strange looking numbers in order to get an average total at the bottom.
    I have seen an average calculation button on some ALVs and was wondering if it's possible to change the ALV settings in the code of FBL5N in order to get this to show?  At the moment I can only total and subtotal, there is no average calculation button showing.
    Or, if you can think of another solution, any suggestions gratefully received.  The last resort is asking the user to download the data to excel and calculate the average there.
    Thanks,
    Gill

    hi
    select the column,  which u have to calculate the average .
    and select edit menu ->calculate->Mean value
    regards
    surender

  • 'Average Weighted with Calendar Days' in Exception Aggregation

    Dear specialists,
    I have created a query with a lot of calculated keyfigures.
    One of my calculated keyfigures shows percentage values.
    When I select a calendar day, my report shows correct results
    for the percentage values.
    But when I execute the report without selecting a calendar day,
    I get strange results like 3,21 % instead of 97,49 %.
    There is a new functionality with version 7.0, where we can set
    Aggregation properties like 'Average Weighted with Calendar Days' .
    But when I select this with Ref. characteristic 'calendar day',
    my report does not show any value or any result.
    Are there any other properties to set in Aggregation or Calculations.
    Please give me more information about this issue
    regards Osman Akuzun

    Hi,
           When you define an Exception aggregation on number of work days. There might be some reference characteristic defined in your Bex.
    For exmaple, take a scenario like below. Your BW data is like below
    0Employee           StockIssued
    XXX                            50                                
    XXX                            10              
    YYY                           20              
    YYY                            30             
    YYY                            40             
    ZZZ                            50              
    ZZZ                            100            
    ZZZ                            30              
    Suppose the first row which has values like XXX and 50 is not a working day and remaining all are working days then the exception aggregation applied using AV2 on the characteristic  0Employee will be caluclated in your Report as below
    For XXX, it will       10/1 = 10 (because only 1 working day for the employee XXX)
    For YYY, it will       90/3 = 30 (because all  3  are working days for the employee YYY)
    For ZZZ, it will       180/3 = 60 (because  all  3  are working days for the employee ZZZ)
    This is how the exception aggregation works. Try to see the similar kind of example in your system and try to relate in the same lines explained by me. You can understand.
    Regards
    Sunil

Maybe you are looking for

  • JavaFX applet crashes while setting Group visible

    Hi, I have a big problem with my JavaFX applet. Sometimes I have to switch the visibility of some Groups in my applet. But often the GUI crashes and I have to close the browser and start it again. I think it's just the GUI that chrashes because the J

  • PNPBEGDA and PNPENDDA

    Hello, I am using the PNP logical database along with HR Report category set to HRDEOD01. The selection screen works fine for 'Payroll Period' tab. However, if I were to choose date range from 'period' like - Today / Current Month / Current year, etc

  • Query buttons not working inside dynamic regions

    Hi Using: Jdev 11.1.1.2.0 I have created an index page with a menu whose menu items navigate to dynamic regions. On each of the jsff pages I have an ADF Query Panel with Table. Problem, none of the Query Panel's buttons seem to be working. Clicking o

  • What is plugin variablespalette used for?

    I suddenly have a message at startup "Error Loading Plugins   Variablespalette.aip".  I click continue and Illustrator opens up fine and I can do all my work.  I have another PC running same OS and CS which does not get this error.  So I copied the f

  • AIA PIPs  CurrencyExchangeList BUG or Limitation...

    Hi All, The BPEL process is a Oracle standard process (PIPs) CurrencyExchangeListEbizJMSProducer, but still we are getting the error. The below error in red I took from server log file. We are getting an error in Production environment while a BPEL p