Calculate the sum of the duration stored in format HH24

Dear professionals,

I use Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production. I stored length of certain events in the table TIME_DURATION as as follows (format h24:mi):

CREATE TABLE "TIME_DURATION" ("ID" NUMBER(11,0), "HOURSMINUTES" VARCHAR2(5));

Insert into TIME_DURATION (ID,HOURSMINUTES) values ('5','00:55');
Insert into TIME_DURATION (ID,HOURSMINUTES) values ('7','00:18');
Insert into TIME_DURATION (ID,HOURSMINUTES) values ('9','06:34');
Insert into TIME_DURATION (ID,HOURSMINUTES) values ('15','00:12');
Insert into TIME_DURATION (ID,HOURSMINUTES) values ('17','09:50');
INSERT INTO TIME_DURATION (ID,HOURSMINUTES) VALUES ('41','12:39');

select * from time_duration;

        ID HOURS
---------- -----
         5 00:55
         7 00:18
         9 06:34
        15 00:12
        17 09:50
        41 12:39

6 rows selected.

Now, I want to calculate the total time for all events (sum of all specific times). In this case, it should be 30 hours and 38 minutes.

Any help would be much appreciated.

Thanks in advance.

Hello

So, you want to add a number of lines varibale.  This sounds like a job for the SUM function.  AMOUNT of work on numbers, no channels such as time, so use TO_NUMBER to convert strings to numbers, so you can add them.  If you want to display the result as a string, you can use TO_CHAR to convert the sum into a string.

WITH got_total_minutes AS

(

SELECT SUM ((TO_NUMBER (SUBSTR (heure, 1, 2) * 60)))

+ TO_NUMBER (SUBSTR (hour 4))

) AS total_minutes

OF time_duration

)

SELECT TRUNC (total_minutes / 60). ':'

|| To_char (MOD (total_minutes, 60))

, "FM00.

) AS total_hours_minutes

OF got_total_minutes

;

The output is not quite what you asked:

TOTAL_HOURS_MINUTES

--------------------

30: 28

If you really want 30:38', explain how to get it.

This solution assumes that time always is always 5 characters (2 digits, a separator and another of 2 digits) as it is in your sample data.

If your actual data aren't like your sample data, the same approach still works, but the SUBSTR expressions will be more complicated.

adnanBIH wrote:

Dear professionals,

I use Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production. I stored length of certain events in the table TIME_DURATION as as follows (format h24:mi):

  1. CREATE TABLE 'TIME_DURATION' ('ID' NUMBER (11.0), VARCHAR2 (5)) 'HOUR '.
  2. Insert into TIME_DURATION (ID, TIME) values ('5',' 00:55 ');
  3. Insert into TIME_DURATION (ID, TIME) values ('7',' 00:18 ');
  4. ...

Thanks for posting the CREATE TABLE and INSERT.

ID is a NUMBER, so do not use quotes around it:

Insert into TIME_DURATION (ID, TIME) values (5, ' 00:55 ');

Insert into TIME_DURATION (ID, TIME) values (7, ' 00:18 ');

...

Depending on how you plan to use the hour, you may want to store a NUMBER, also, or maybe an INTERVAL DAY TO SECOND.

Tags: Database

Similar Questions

  • Help: How do I calculate the duration between 2 dates, when these dates on 2 rows?

    Hello

    We are 11g.

    We have a table with times recorded in a column. Then, each line as a different date value.
    There is no pb to order the query on this date column (obviously)

    Now, we need to calculate the period of time between 2 successive rows.
    I first thought to use a cursor, the cursor loop, compute and update the "duration" column
    It's the basic option

    Now, I would like to know if, by using a single query, I couldn't directly the calculation I want?

    Here is my example:
    WITH t AS (
    SELECT 'aaa' col1, to_date( '20100201 09:23:50', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
    UNION
    SELECT 'aaa' col1, to_date( '20100201 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
    UNION
    SELECT 'aaa' col1, to_date( '20100207 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
    UNION
    SELECT 'bbb' col1, to_date( '20100202 09:21:10', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
    UNION
    SELECT 'bbb' col1, to_date( '20100203 08:11:06', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
    UNION
    SELECT 'bbb' col1, to_date( '20100203 15:13:55', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
    UNION
    SELECT 'bbb' col1, to_date( '20100210 10:14:27', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
    ) 
    SELECT col1, to_char( date1,'YYYYMMDD HH24:MI:SS') date1  FROM t
    ORDER BY col1, date1;
    Ideally, that's what I would get (if my math is correct)
    COL DATE1               DURATION
    --- ----------------- ----------
    aaa 20100201 09:23:50          0
    aaa 20100201 13:14:33      13843
    aaa 20100207 13:14:33     518400
    bbb 20100202 09:21:10          0
    bbb 20100203 10:11:06      89396
    bbb 20100203 15:13:55      18169
    bbb 20100210 17:14:27     612032
    I hope I'm clear!

    Thanks a lot in advance for your help
    Olivier

    Of course; It's easy with the use of the function analytic lag:

    WITH t AS (SELECT 'aaa' col1, to_date( '20100201 09:23:50', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
               UNION ALL
               SELECT 'aaa' col1, to_date( '20100201 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
               UNION ALL
               SELECT 'aaa' col1, to_date( '20100207 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
               UNION ALL
               SELECT 'bbb' col1, to_date( '20100202 09:21:10', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
               UNION ALL
               SELECT 'bbb' col1, to_date( '20100203 08:11:06', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
               UNION ALL
               SELECT 'bbb' col1, to_date( '20100203 15:13:55', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
               UNION ALL
               SELECT 'bbb' col1, to_date( '20100210 10:14:27', 'YYYYMMDD HH24:MI:SS') date1 FROM dual),
    t_diff as (SELECT col1,
                      to_char( date1,'YYYYMMDD HH24:MI:SS') date1,
                      (date1 - lag(date1, 1, date1) over (partition by col1 order by date1))*24*60*60 date_diff
               FROM   t)
    select col1,
           date1,
           sum(date_diff) over (partition by col1 order by date1) duration
    from   t_diff
    ORDER BY col1, date1;
    

    Published by: Boneist on February 15, 2010 16:39
    (I can't read; initially gave the cumulative total of the period. Oh!)

    ETA2: Take note of the additional parameters, I used in the lag() - the third parameterd manages what should be the value in the field if there is no previous rank, so there is no need to use nvl elsewhere in the application to handle this situation.

    Published by: Boneist on February 15, 2010 16:42

  • calculate the duration

    data

    From time to time

    November 10, 2015 16:00 November 10, 2015 17:10

    November 10, 2015 16:50 10 November 2015 18:00

    November 10, 2015 17:15 November 10, 2015 23:00

    November 10, 2015 17:30 November 10, 2015 22:20

    November 10, 2015 19:35 November 10, 2015 19:50

    from the first record, if I want to calculate the time duration that is, 70 min.

    second disc begins to the first record. service time is now 18-16 120 min.

    third record also begins in the second.  duration is now 300 min 23-16.

    fourth and fifth registration is the responsibility of the third record time.

    so final duration is 18-16 = 120 min.

    How can I achieve this. Please just write the sql query.

    Thank you.

    teefu.

    Lahore. in Pakistan.

    SQL>
    SQL> --
    SQL> select * from dt_lines order by f_dntime, t_dntime;
    
        DT_ID F_DNTIME T_DNTIME DT_DUR
    ---------- -------------------- -------------------- ----------
      1 10-Nov-2015 16:00:00 10-Nov-2015 17:10:00    70
      2 10-Nov-2015 16:50:00 10-Nov-2015 18:00:00    130
      3 10-Nov-2015 17:15:00 10-Nov-2015 23:00:00    345
      4 10-Nov-2015 17:30:00 10-Nov-2015 22:20:00    290
      5 10-Nov-2015 19:35:00 10-Nov-2015 19:50:00    15
      6 10-Nov-2015 23:15:00 10-Nov-2015 23:45:00    30
    
    6 rows selected.
    
    SQL>
    SQL> --
    SQL> with t as (
      2  select f_dntime, t_dntime,
      3  case when min(f_dntime) over (order by f_dntime, t_dntime rows between unbounded preceding and 1 preceding) is null
      4      then f_dntime
      5      when f_dntime > max(t_dntime) over (order by f_dntime, t_dntime rows between unbounded preceding and 1 preceding)
      6      then f_dntime
      7  end as max_fdt_adjusted
      8    from dt_lines
      9  ),
    10  t1 as (
    11  select f_dntime, t_dntime, max_fdt_adjusted,
    12  last_value(max_fdt_adjusted ignore nulls) over (order by f_dntime) as min_from_ts
    13    from t
    14  )
    15  select min_from_ts, max(t_dntime) as max_to_ts,
    16      round((max(t_dntime) - min_from_ts)*24*60) as duration_min
    17    from t1
    18  group by min_from_ts
    19  order by min_from_ts
    20  ;
    
    MIN_FROM_TS    MAX_TO_TS  DURATION_MIN
    -------------------- -------------------- ------------
    10-Nov-2015 16:00:00 10-Nov-2015 23:00:00  420
    10-Nov-2015 23:15:00 10-Nov-2015 23:45:00    30
    
    2 rows selected.
    
    SQL>
    SQL>
    
  • My Apple Watch is not accurately calculate the duration of my exercise

    Yesterday morning, I worked with a personal trainer for an hour. We checked my heart rate using my Apple Watch periodically throughout the workout, and, on average, she recorded about 160 BPM. It was a hard workout, and I was absolutely exhausted at the end of the hour. However, when I checked the activity Tracker on my Apple Watch, he said I had only worked for 22 minutes. I calibrated my Apple Watch. Why my intense workout of an hour is not save to my Apple Watch?

    Hello

    Progress towards your goal of exercise of credit, the application of the activity is to identify the activity equal or exceed the intensity of a brisk walk. The definition of this varies based on the personal information. To check that your personal information is accurate:

    -On your iPhone, in the application of Eve, go to: My Watch tab > health > change.

    For the purposes of rehabilitation appropriations in General everyday wear, enforcement activity relies on movement of arm (measured by accelerometer). For best results, let the arm on which you wear your watch to swing naturally as you exercise. If you have not saved your activity as a workout, it was the only information that has been taken into account in the allocation of the appropriations for the year.

    In addition to using the accelerometer data, the training app allows also the heart rate sensor data and - for outdoor activities - GPS data (when they are available via the iPhone paired).

    The heart rate sensor is likely to give better results for the workouts that involve rhythmic (for example running) rather than the irregular movements (weight, for example). For best results, your watch should sit comfortably against the top of the wrist. For best performance, Apple suggests you consider your clamping watch band before workouts and it loosen again thereafter. For the exercises or other activities that involve bending your wrist, it can also help to move your watch further to the top of your arm.

    If you want to save the entire workouts as exercise regardless of their levels of intensity, follow them through the application of training using others as the type of activity. This credit a minute of exercise for each minute of the workout.

    More information:

    Use the activity on your Apple Watch - Apple Support

    Use of the workout on your Apple Watch - Apple Support

  • calculate the time difference between several lines

    Hello

    I have a table as below:

    create table select TEST_CASETBL (ID, CASE_NUM, CASE_STATUS, CASE_SUB_STATUS, LAST_UPD_DTTM)

    112, 123-456', 'open', 'Work', TO_DATE (11 March 2015 13:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    113, 123-456', 'Open', 'pending on the admin', TO_DATE (10 January 2015 15:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    114, 123-456', 'Open', 'client expectation', TO_DATE (10 July 2015 09:00 ',' hh24:mi:ss' of dd/mm/yyyy) of the DUAL union all select them

    315, 123-456', 'open', 'Work', TO_DATE (September 15, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    219, 123-456', 'Open', 'pending on the admin', TO_DATE (January 9, 2015 08:00 ',' dd/mm/yyyy hh24:mi:ss') of the DUAL union all select

    651, 123-456', 'open', 'Work', TO_DATE (August 20, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') from DUAL;

    I would like to calculate the duration total (days ideally) to CASE_SUB_STATUS, so have a set of lines:

    CASE_NUM of work waiting on admin waiting on customer

    -------------------------------------------------------------------------------------------------------------------------------------------------------

    123-456 70days 6 hours

    Here is the explanation of the pattern:

    ex: for everyday business computing (timestamp timestamp of ID:651 - ID:219) +(timestamp of ID:315-timestamp of ID:114) + (ID:112 stamp - current_time) = 11 days + 21 days 22hrs 23hrs 36 days 9 hours

    still waiting on admin

    (ID:219 timestamp - timestamp of ID:315) + (ID:113 timestamp - timestamp of ID:112)

    still waiting on the client

    (ID:114 timestamp - timestamp of ID:113)

    I would appreciate any idea how to solve this, ideally as an SQL

    Thank you

    Should he not?...

    with test_casetbl (id, case_num, case_status, case_sub_status, last_upd_dttm) as)

    Select 112, 123-456', 'Open', 'Work', TO_DATE (11 March 2015 13:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 113, 123-456', 'Open', 'pending on the admin', TO_DATE (10 January 2015 15:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 114, 123-456', 'Open', 'client expectation', TO_DATE (10 July 2015 09:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 315, 123-456', 'Open', 'Work', TO_DATE (September 15, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 219, 123-456', 'Open', 'pending on the admin', TO_DATE (January 9, 2015 08:00 ',' dd/mm/yyyy hh24:mi:ss') of all the DOUBLE union

    Select 651, 123-456', 'Open', 'Work', TO_DATE (August 20, 2015 10:00 ',' the hh24: mi: ss' dd/mm/yyyy) double

    ),

    t like)

    Select case_num,

    case_sub_status,

    (last_upd_dttm, 1, sysdate) ahead of diff last_upd_dttm (partition by order of last_upd_dttm case_num).

    of test_casetbl

    )

    Select case_num,

    trunc (a) | "day (s). TO_CHAR (date ' 1-1-1' + a, "fmhh24" 'mi' minute (s) "ss" second (s) hour (s)"") "work."

    trunc (b) | "day (s). TO_CHAR (day 1-1-1' + b, "fmhh24" 'mi' minute (s) "ss" second (s) hour (s)"") 'Waiting on admin',

    trunc (c) | "day (s). TO_CHAR (day 1-1-1' + c, "fmhh24" 'mi' minute (s) "ss" second (s) hour (s)"") "waiting on customer."

    t

    pivot)

    Sum (diff)

    for case_sub_status in)

    'Work' is.

    B "waiting on admin',

    C "customer expectation."

    )

    )

    CASE_NUM Working Waiting on admin Waiting on customer
    123-456 63 day (s) 22 hour (s) (s) 50 minute 49 second (s) 19 day (s) on 20 (s) hour 0 minute 0 second (s) 27 day (s) on 4 hour (s) 0 minute 0 second (s)
  • How to calculate the sum of the fields to fill?

    Hello!

    My question is how can I calculate the sum of filled areas?

    For example, in a PDF document, I have a few fields that must be filled out with name and surname and the end of the document, another field that is the sum of the fields "FullName" which shows how many people is in this document. The operation should not take into account white/empty areas.

    Now, I know that I could do with the simple calculation "(+) sum" but I have to put a '1' for each of this area and I would like to avoid this.

    Yes, it's the first option I described. In this case, you can use this code:

    var total = 0;
    for (var i=1; i<=79; i++) {
        if (this.getField("Nume si prenume "+i).valueAsString!="") total++;
    }
    event.value = total;
    
  • Adobe Acrobat Standard DC - calculate, the value is the "sum" of

    The "text field properties / calculate / value is the 'sum' of the following fields / pinch / field selection"window does not provide any options to select. "  I formatted all the fields in the source & field sum as 'number' and out spaces in domain names.  My version of Acrobat Standard DC excludes a Sum function?  Thank you, all!

    It displayed fine. It looks good, so I don't know why there is no fields displayed when you click the button to 'Pick '. I always use the JavaScript option, but you can try the option of simplified field notation to work around the problem. You need to enter something like:

    Field1, Field2, field3 and field4

    Where are the names of the fields that you want to calculate the total, so change to match your domain names.

  • How to calculate the sum of two digital form fields based on the selection of the checkbox.

    I have a form in Acrobat Pro who needs a custom calculation. How to calculate the sum of two digital form fields based on a selection of the checkbox. I have three number fields. Field-A and B are simple one or two digits. Field-C is the sum, or the total field. I want to field-C have a control box which, when turned on and off, just gives a. gives the sum of A + B

    _ Field - 2

    _ Field - A 4

    [check] _ _ field - 6 C

    [disabled] _ _ field - 2 C

    Thank you

    The custom field C calculation script could be:

    (function () {
    
        // Get the values of the text fields, as numbers
        var v1 = +getField("A").value;
        var v2 = +getField("B").value;
    
        // Set this field's value based on the state of the check box named "CB"
        if (getField("CB").value !== "Off") {
            event.value = v1 + v2;
        } else {
            event.value = v1;
        }
    
    })();
    

    Replace 'A', 'B', and 'CB' with the real names of the fields.

  • Calculate the sum of the columns

    Hello!

    Am using jdeveloper 11.1.2.1

    I created a table VO based EO. I need to calculate the sum of the column named price.

    I use the expression PoView.sum ("Price"). In this PoView is the name of VO and the price is the name of the column.

    While spin AMModule I got an exception like

    PoView name not found in the given object.

    Hello

    You must use the name accessor EO or VO instead of the name of VO.
    See https://blogs.oracle.com/adf/entry/using_groovy_aggregate_functions_in (there are even the same error message in one of the comments of this blog)

    concerning
    Peter

  • Calculate the sum involved new VO

    Gurus,

    I want to have a sum of column values in a table. I looked at a number of post on OTN, but it does not work
    Created a transitional attribute in the VO. expression and passed to the next value
    VO.getRowSet().sum("((Mtd == null) ? 0 : Mtd)
    also tried
    adf.object.getRowSet().sum("((Mtd == null) ? 0 : Mtd)
    and
    object.getRowSet().sum("((Mtd == null) ? 0 : Mtd)
    MTD is the column in the original Version I want to calculate the total

    Can you please advice what's not here

    thnks

    Published by: in the line of fire on August 10, 2011 10:46

    I've tried this so 11.1.1.4, not 11.1.1.5 but it should work.

    You can keep the condition in the expression:
    object.getRowSet (.sum) (' bat == null? 0: Mtd')
    to make sure that you have no problem with null values.

    Apart from this, make sure that everything is in the type of data in the database and the VO.

    Gabriel.

  • CALCULATE the sum of the amounts?

    Hey guys!

    This script:
    CLEAR      COMPUTES 
    CLEAR     BREAKS
    
    SET     feedback     off
    SET     pagesize     5000
    SET     linesize     50
    SET     echo          off
    SET     heading          on
    SET     verify          off
    
    COLUMN     User format     A8
    COLUMN     Files format     999999999
    COLUMN     Docs format     999999999
    COLUMN     Pages format     999999999
    
    COMPUTE SUM LABEL TOTAL OF "FILES", "DOCS", "PAGES"
    
    PROMPT     ************************************************** 
    PROMPT     *         Monthly File Activity by User          *
    PROMPT     ************************************************** 
    PROMPT      
    PROMPT      
    ACCEPT     StartDate     DATE FORMAT 'MMYYYY'      PROMPT 'Enter the month and year (MMYYYY): '
    PROMPT     
    PROMPT      List of users:
    PROMPT      One
    PROMPT      Two
    PROMPT      Three
    PROMPT      Four
    PROMPT      Five
    PROMPT      Six
    PROMPT      Seven
    PROMPT     UNKNOWN
    PROMPT       
    PROMPT     Type 'ALL', or leave blank, to select all users.
    PROMPT      
    ACCEPT     UserChoice     DEFAULT 'ALL'     PROMPT 'Please enter a user: '
    
    
    SELECT
         (CREATOR_ID
                       WHEN     '1'     THEN     'One'
                     WHEN     '2'     THEN     'Two'
              WHEN     '3'     THEN     'Three'
              WHEN     '4'     THEN     'Four'
              WHEN     '5'     THEN     'Five'
              WHEN     '6'     THEN     'Six'
              WHEN     '7'     THEN     'Seven'
              ELSE     'UNKNOWN'
              END)     "USER",
         count       (distinct(substr(DOC_NAME,1,9))) AS Files,
         count     (DOC_IMAGE) AS Docs,
         sum     (DOC_PAGE) AS Pages
    FROM
         TABLE1,
         TABLE2
    WHERE
         DOC_DATE to_date('&StartDate','MMYYYY') AND last_day(to_date('&StartDate','MMYYYY'))
    AND
         CREATOR_ID not in ('Thing','8','9')
    AND
         ((CREATOR_ID
                       WHEN     '1'     THEN     'One'
                     WHEN     '2'     THEN     'Two'
              WHEN     '3'     THEN     'Three'
              WHEN     '4'     THEN     'Four'
              WHEN     '5'     THEN     'Five'
              WHEN     '6'     THEN     'Six'
              WHEN     '7'     THEN     'Seven'
              ELSE     'UNKNOWN'
              END) = UPPER('&UserChoice')
         OR
         '&UserChoice' = 'ALL')
    GROUP BY
         CREATOR_ID
    /
    produces this result:
    USER          FILES       DOCS      PAGES
    -------- ---------- ---------- ----------
    One             261       4276      18124
    Two             364       5954      26913
    Three           109       1996       8243
    Four            178       3635      14554
    Five            104       2657      11662
    Six             308       6639      27887
    I would like for a labeled sum TOTAL at the bottom of these figures. I thought that COMPUTE would take care of this, but it's not. Am I missing something? It will not add these to the top because they are already money from specific users? Insight? I'm new to SQL and would like to be pointed in the right direction. Thanks for your expertise!

    I'm on a 10g system.

    Calculation is not SQL and SQL * more.
    The general syntax is
    calculate the sum of... the * | * report

    followed by
    break the report
    When this is necessary.

    -----------
    Sybrand Bakker
    Senior Oracle DBA

  • calculate the sum of the two columns - display the result in the third column

    Hello

    I have a report and I want to calculate the sum of the two columns of the report and display the total in the third column.

    For example: Sample_My_Report

    Col1 Col2 (Col1 and Col2) Total

    3-7-10


    can someone help me with this question.

    Thank you.

    Hello:

    If your report is an IR you can use the menu "Tool" to add columns calculated at the State

    CITY

  • Use the project start Date and duration to calculate the end Date of project

    I'm trying to calculate the end date of the project in a report using the project end Date and time entered on the opportunity.
    For example, if the start date of the project filled an opportunity is 31/01/2009 and the length (integer) is entered on the opportunity is 5, the project end date is in the report must be 30/06/2009.

    I'm trying to TIMESTAMPADD forumaul allows you to add the duration (number of months) to the project start date
    This Fx works TIMESTAMPADD (SQL_TSI_MONTH, 12, '-used Custom Attributes ".) DATE_40)
    But if I try to replace the number twelve by the length (integer field) I get an error when you try to save: TIMESTAMPADD (SQL_TSI_MONTH, "-opportunity Custom Metrics".) S_INT_0, '-used custom attributes. DATE_40)

    Any ideas on how I can get this to work would be greatly appreciated.

    Hi, try this. It might solve your prioblem TIMESTAMPADD (SQL_TSI_MONTH, CAST (YOUR FIELD AS INTEGER), account. (' "Last modified")

    -John CRMIT

  • How to calculate the periods that overlap between two or more given the date range?

    Hi all

    If there are several durations then how we can calculate the period of time that overlap between these times.

    For example: for 3 time periods. 03/12/2015-16/08/2015, 05/01/2015 to 31/07/2015 and the 06/09/2015 to 30/11/2015, how the overlap period can be calculated?

    There are many potential unknowns in your question.  For example, you want to count any overlap at all?  If two dates overlap, what matters?  Overlap - each of them?

    In any case, here is a solution that counts how many periods are overlapping in any point in time...  She, of course, using temporal logic.  You can then use ValueAt(), WhenLast(), WhenNext(), etc. as appropriate.

    Assume that your model has a child entity called 'the period' with name 'all time periods' relationship and basic attributes 'start date of the period of time' and 'date of end of period of time'.

    In your example:

    an entity should have the time period start date = 03/12/2015 and the date of end of period of time = 16/08/2015

    another entity might have the time period start date = 01/05/2015 and the date of end of period of time = 31/07/2015

    another entity might have the time period start date = 06/09/2015 and the date of end of period of time = 30/11/2015

    To find the number of overlapping over time, we want to count or entities that have an active period, so the rule is perhaps the sum:

    the number of overlapping = the number of all the periods for which it is true that the time period is active

    How do we know a time is active?  This is the time logic comes in.  He is active on or after the start date or no later than the end date:

    the time period is active if

    TemporalOnOrAfter (the date of beginning of period of time) and

    TemporalOnOrBefore (date of end of period of time)

    That's all.  Now, you can perform a temporal visualization of the 'number of overlapping' and you'll see it rise and fall over time.  As a reference, he said that the number of overlapping = 3.0 from 06/09/2015 across 31/07/2015.

    I hope this helps.  You can use the same model to count periods of time functions, but you end up having to use the most logical date.  You of course can count the total number of entities and compare this number of overlap over time to see if they overlap, but I digress...

  • Calculate the amount in an entity does not contribute to the parent


    Hello

    I'll try to explain my problem.

    I need to put in a base entity (E01) the opposite of the value stored in another entity (E02) for the same account (A01) and PKI (PKI no), but for a different value of custom3;
    the expresison used is the following:

    Void calculate)

    ...

    If HS. Entity.Member = E01 then

    HS. Exp ' an A01 #.» I have #[ICP no]. C3 C3 #02 HS =. GetCell ("a #A01.") I have #[ICP no]. E #E02. C3 C3 #01") *-1.

    end if

    ...

    End Sub

    The rule works for E01 entity, but the problem is that when the consolidation runs, the amount so calculated in E01 the sum is not in the parent company of E01.

    Thanks in advance

    Andrea

    Hello Andrea,

    You may need to replace:

    If HS. Entity.Member = E01 then

    with

    If HS. Entity.Member = E01 and HS. Value.Member = "" then

    Kind regards

    Thanos

Maybe you are looking for