difference between two dates in the year/month/day in Obiee

Hi gurus,

I know this question have been asked and answered several times but I have a requirement that is a little different, then the previous ones.

I want to calculate the difference between two dates in OBIEE10g in year/month/day format similar to the below SQL output

SQL > select end_date, start_date,

trunc (months_between (end_date, start_date) / 12) years.

months of mod (trunc (months_between (end_date, start_date)), 12).

End_date - add_months (start_date, trunc (months_between (end_date, start_date))) days

t

Thanks in advance

SK

Search for this

"TIMESTAMPDIFF IN THE FORM OF MTHS # YEARS."

or else

To get the current mandate of employees since the date of hiring in the form of # years # mths or # year (s) # month (s)

Concat (concat (cast (TIMESTAMPDIFF (SQL_TSI_Month, "Employee attributes". (((' ' Hiring last Date employee ", CURRENT_DATE) / 12 as char),"Year (s)"), concat (cast (MOD (TIMESTAMPDIFF (SQL_TSI_Month,"Employee attributes". (((((' ' Hiring last Date employee ", CURRENT_DATE), 12) as char), 'Month (s)'))

Concat (concat (CAST (TIMESTAMPDIFF (SQL_TSI_YEAR, "Employee attributes". (((' ' Hiring last Date employee ", CURRENT_DATE) as CHAR),"Year (s)"), concat (cast (MOD (TIMESTAMPDIFF (SQL_TSI_Month,"Employee attributes". (((((' ' Hiring last Date employee ", CURRENT_DATE), 12) as char), 'Mth (s)'))

Tags: Business Intelligence

Similar Questions

  • How to find the difference between two dates in the presentation layer

    Hi gurus,

    Hello to everyone. Today, I came with the new requirement.


    I need to know the difference between a date and the current date in the formula column application presentation layer.by.



    Thank you and best regards,
    Prates

    Hi Navin,

    TIMESTAMPDIFF function first determines the timestamp component that corresponds to the specified interval setting. For example, SQL_TSI_DAY corresponds to the day component and SQL_TSI_MONTH corresponds to the component "month".

    If you want to display the difference between two dates in days using SQL_TSI_DAY, unlike butterflies SQL_TSI_MONTH and so on...

    hope you understand...

    Award points and to close the debate, if your question is answered.

    See you soon,.
    Aravind

  • Number of days between two Dates in the Correct month

    I am trying to write a SELECT statement that returns the number of days spent on a project.

    Here's my problem. I have a table with several columns of date (start_date, end_date, etc.) as well as several other columns. Here is an example of the table.

    PROJECT... START_DATE... END_DATE
    123 ................. 1ST JANUARY 13... 15 JANUARY 13
    456 ................. 25 JANUARY 13... FEBRUARY 5, 13
    789 ................. 30 JANUARY 13... FEBRUARY 5, 13
    999 ................. 1ST FEBRUARY 13... FEBRUARY 8, 13

    I'm counting the number of days spent on projects in each month. For example, with the above data, I would come back...

    MONTHS... PROJECT_DAYS
    Jan ............. 24
    Feb ............. 18

    I tried to use a CASE statement, but I'm having a hard time to understand. Any help would be greatly appreciated!

    Published by: 987079 on February 8, 2013 13:12

    An option would be something like

      1  with project as (
      2    select 123 project_id, date '2013-01-01' start_date, date '2013-01-15' end_date from dual union all
      3    select 456, date '2013-01-25', date '2013-02-05' from dual union all
      4    select 789, date '2013-01-30', date '2013-02-05' from dual union all
      5    select 999, date '2013-02-01', date '2013-02-08' from dual
      6  ),
      7  all_days as (
      8    select start_date + level - 1 dt
      9      from (select min(start_date) start_date,
     10                   max(end_date) end_date
     11              from project)
     12   connect by level <= end_date - start_date + 1
     13  )
     14  select trunc(dt,'MM'),
     15         count(*)
     16    from all_days ad
     17         join project p on (ad.dt between p.start_date and p.end_date)
     18   group by trunc(dt,'MM')
     19*  order by trunc(dt,'MM')
    SQL> /
    
    TRUNC(DT,'MM')        COUNT(*)
    ------------------- ----------
    2013-01-01 00:00:00         24
    2013-02-01 00:00:00         18
    

    Justin

  • Difference between two dates in the server behaviors

    Hello all,.

    I am trying to create a Recordset by using server behaviors and that I'm not an expert in php, I'm completely lost...

    The problem is this: I want to find in a table of all the records where the difference between today's date and date of creation (stored in this table, although course) is superior to, say 30 days. How can I specify the variable field?

    Thank you very much in advance for your help!

    You must use a sql like query below:

    SELECT * FROM table WHERE creationDate< date_sub(now(),="" interval="" 30="">

    'table' is the name of the table that you want to select the information of and 'creationDate' being the column 'date' in the database

  • Difference of two dates in the month

    I need to find the difference between two dates as the number of months:
    find the last day of the month of the two dates. subtract and give the difference in number of months.

    user637544 wrote:
    I need to find the difference between two dates as the number of months:
    find the last day of the month of the two dates. subtract and give the difference in number of months.

    Why not just use MONTHS_BETWEEN function? That does not help?

    SQL> SELECT sysdate FROM Dual;
    
    SYSDATE
    ---------
    01-JUN-09
    
    SQL> SELECT MONTHS_BETWEEN (SYSDATE,
      2                         TO_DATE ('01/01/2009', 'DD/MM/YYYY')
      3                        ) diff_in_months
      4    FROM DUAL;
    
    DIFF_IN_MONTHS
    --------------
                 5
    
    SQL>
    

    You can also use the LAST_DAY function to get the last day of the month.

    SQL> SELECT LAST_DAY(sysdate) FROM Dual;
    
    LAST_DAY(
    ---------
    30-JUN-09
    
    SQL> SELECT MONTHS_BETWEEN (LAST_DAY(SYSDATE),
      2                         LAST_DAY(TO_DATE ('01/01/2009', 'DD/MM/YYYY'))
      3                        ) diff_in_months
      4    FROM DUAL;
    
    DIFF_IN_MONTHS
    --------------
                 5
    
    SQL>
    

    Kind regards
    JO

    Published by: Joice John - added LAST_DAY function example

  • Find the difference between two date and time

    Hi friends,

    I wanted to find the difference between two date and time, but my qury is slightest error "invalid number."

    select sql_step_num,proc_name,run_seqno,start_date,end_date,(to_char(start_date,'HH24-MI-SS') - to_char(end_date,'HH24-MI-SS') ) as ed  
    from eval.EVAL_RUNTIME_DETAILS
    where trunc(start_date) = trunc(sysdate) 
    order by sql_step_num;

    You try to get the feel between two char strings.
    And more difference between two dates gives a NUMBER of days.
    Try this:

    select sql_step_num,proc_name,run_seqno,start_date,end_date,numtodsinterval(end_date-start_date,'DAY') as ed
    from eval.EVAL_RUNTIME_DETAILS
    where trunc(start_date) = trunc(sysdate)
    order by sql_step_num;
    
  • How do the time difference between two dates?

    Hi all

    I use this query to get the time difference between two dates.

    Select to_timestamp ('2012-10-03 12:00 ',' YYYY-MM-DD hh)-to_timestamp ('2012-10-03 11:00 ',' YYYY-MM-DD hh) as double diff;

    but do not get the correct result.

    Thank you

    Left KEY... Left Padding of tanks.

  • Dynamic action - Get the difference between two dates + times

    I have problems a little dynamic to work action. I'm trying to get the time between two dates with the time difference.

    Here is what I got (this is apex 4.0):

    Two date pickers + two numbers fields (date/start/end times)

    I created a dynamic action on the page who fires on the point lose focus (above points).

    The real action for the DA is the body of the PL/SQL function:
    declare
      end_date DATE;
      start_date DATE;
    Begin
      start_date := to_char(:P1_START_DATE || ' ' || :P1_START_TIME, 'DD-MON-YYYY HH:MIAM');
      end_date := to_char(:P1_END_DATE || ' ' || :P1_END_TIME, 'DD-MON-YYYY HH:MIAM');
      :P1_HOURS := end_date-start_date;
    End;
    When I change the values on the page, I get the following error:

    AJAX call back Server error ORA-06502: PL/SQL: digital or value error: character number conversion error to set the value.

    I'm guessing that there is a problem with the date formatting, but I can't make it work. Thanks in advance!

    Hi djston,

    because you chose the dynamic action of 'Set value' with the "Body of the PL/SQL function" type you need to return the value. Try the following code

    declare
      end_date DATE;
      start_date DATE;
    Begin
      start_date := to_date(:P1_START_DATE || ' ' || :P1_START_TIME, 'DD-MM-YYYY HH:MIAM');
      end_date := to_date(:P1_END_DATE || ' ' || :P1_END_TIME, 'DD-MM-YYYY HH:MIAM');
      RETURN (end_date-start_date)*24;
    End;
    

    and P1_REQUESTED_HOURS like 'item affected. "

    Concerning
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

    Published by: Patrick Wolf on January 17, 2011 10:54

  • The date system in the taskbar indicates the year, month, day (as in the army). How can I read the day, month, year?

    The date system in the taskbar indicates the year, month, day (as in the army). How can I read the day, month, year?

    It's weird, in my version (Windows 7 Pro), it shows much more than that.

  • Suggest the Sql query to get the years, months, days of the two dates.

    Hi all

    SELECT TO_DATE('06-02-2014','DD-MM-YYYY') - TO_DATE('01-04-1998','DD-MM-YYYY') SERVICE_DAYS OF THE DOUBLE

    5790 SERVICE_DAYS

    POWER REQUIRED:
    YEARS MONTHS DAYS
    15 10 5

    OUTPUT DISPLAY:

    Select
    Floor(5790/ 365.25),
    Floor (mod (5790,365.25) / (365.25 / 12)),.
    ceil (mod(5790,365.25 / 12))
    Double;

    YEARS MONTHS DAYS
    15 10 7 - TWO DAYS MORE


    How they calculate manually is as follows:

    2014 02-06
    1998-04-01
    ---------------
    05 - days

    2014 02-06
    1998-04-01
    + 12
    ---------------
    10 month 02 is lower than 04, so we borrow 12 months of TI (2014) years will be (2013)

    2014 02-06
    1998-04-01
    -(1).
    ---------------
    15. for the years since we-1

    Kind regards

    Afzal.

    OK... so try not not to multiply the reminder to add_months with 30 but to solve the 'day-thing' in a different way...

    first step (data) is only my implementation testdata.

    WITH DATA AS (SELECT TO_DATE('02-03-2014','DD-MM-YYYY') AS Degnide

    TO_DATE('07-04-2008','DD-MM-YYYY') AS dayfrom

    OF the double

    UNION ALL

    SELECT TO_DATE('12-04-2014','DD-MM-YYYY') AS Degnide

    TO_DATE('11-05-1994','DD-MM-YYYY') AS dayfrom

    OF the double

    UNION ALL

    SELECT TO_DATE('06-02-2014','DD-MM-YYYY') AS Degnide

    TO_DATE('01-04-1998','DD-MM-YYYY') AS dayfrom

    OF the double

    )

    calc AS (SELECT months_between (dayto, dayfrom) SERVICE_DAYS

    Degnide

    dayfrom

    DATA)

    SELECT Degnide

    dayfrom

    floor(service_days/12) IN years

    floor (mod(service_days,12)) AS month

    , BUSINESS sign (EXTRACT (Degnide DAY) - EXTRACT (DAY FROM dayfrom))

    WHEN THEN-1 EXTRACT (DAY FROM Degnide) + 30 - EXTRACT (DAY OF THE dayfrom)

    WHEN 0 then 0

    WHEN 1 THEN EXTRACT (Degnide DAY) - EXTRACT (DAY FROM dayfrom)

    0 OTHERWISE

    end as days

    CALC

    HTH

  • How to tell the difference between two dates

    Hello:

    I have a question on how to get the difference in quantities for two dates in the replies and dashboard.

    This is the scenario. I have two guests date and three columns. The first column must be the sum of the amounts for the first quick date. The second column should be the sum of the amounts for the second fast date. And the third column is the difference between the first two columns.

    Basically, I'm trying to do something similar to a function of sum of two lines but trying to get the difference between the two rows. Any help to solve this problem would be appreciated.

    Use the COLUMN FILTERS level...

    the first column with the first variable of date quick presentation of the filter

    Similarly, the second column in the second variable of quick overview of date filter

    Kind regards
    Rambeau

  • Difference between two data aquistion

    Hello

    I got a data aquistion system that is supposed to keep data acquisition selection until the difference between two points a lot. For example, I get voltage (mv) as 2.31, 2.32, 2.34. 2.33 2.32, 2.33 2.32. the data up to a point, say 0.1V higher or lower than the first. Thewhole procss stop. Thank you for your suggestions.

    Try this... (Labview 8.2)

  • Balance sheet for a YEAR between two dates in the dashboard

    Hello

    Could someone help me please how can I calculate the 'balance of the CDA' between two different dates, who is invited to the dashboard? Means: we have an "effective date" and a "prior date" as a promt in the dashboard user who selects dynamically. When displaying in the report, it should show us the "CDA balance" between the two dates selected dynamically by users in the dashbowrd prompt. Please suggest.

    Thanking you,
    BK.

    Now that you understand the concept, it is easy to change the constant (i.e., 2011-01-01) to a variable.

    1) start with your repository variable that contains your current date: CURRENT_DATE

    (2) TIMESTAMPADD (SQL_TSI_DAY, DAYOFYEAR (CURRENT_DATE) *-1 + 1, CURRENT_DATE) is the SQL to get the first day of the year.

    Replace the hardcoded hard 01/01/2011 with the SQL above and now it will work for the beginning of the current year. You can change the SQL code for the beginning of a given year.

    Ex. TIMESTAMPADD (SQL_TSI_YEAR-1, TIMESTAMPADD (SQL_TSI_DAY, DAYOFYEAR (CURRENT_DATE) *-1 + 1, CURRENT_DATE)) you will get the start of "last year." This should help you with your problem.

    Now that you have everything, please mark the appropriate messages 'useful' and 'proper' and then mark the thread as answered and others if you are looking for a similar solution can easily find the answer. Thanks and good luck!

    Edited by: David_T November 28, 2011 07:56

  • How to find the difference between two dates in time except Sunday

    Hi all

    I have a table, as shown below.
    SQL> select * from test;
    
    TR_ID                                              CREATE_TIME                                                                       CODE
    -------------------------------------------------- --------------------------------------------------------------------------- ----------
    S12341                                             05-JUN-12 12.20.52.403000 AM                                                      1003
    S12342                                             11-JUN-12 11.15.33.182000 AM                                                      1003
    S12342                                             07-JUN-12 12.00.36.573000 PM                                                      1002
    S12343                                             20-JUN-12 12.34.37.102000 AM                                                      1003
    S12343                                             15-JUN-12 11.34.27.141000 PM                                                      1002
    S12344                                             01-JUL-12 10.01.06.657000 PM                                                      1002
    S12344                                             06-JUL-12 12.01.04.188000 AM                                                      1003
    S12341                                             31-MAY-12 11.20.38.529000 PM                                                      1002
    I would like to know the difference between same tr_ids create_time, which should give out in hours except Sunday.

    For example:

    TR_ID: S12344
    1002_Create_time: July 1, 12 PM 10.01.06.657000 (i.e. Sunday)
    1003_Create_time: 12.01.04.188000 AM 6 July 12

    1002 create time is 22:00 Sunday.

    If the query must exclude only the hours of Sunday which is 10 p.m. to Monday 00 h which is 2 Hrs.

    I tried the sub query after doing a search on this forum but I am not getting the desired output.
    SELECT count(*) FROM (SELECT ROWNUM RNUM,tr_id,create_time CT_1002 FROM test c WHERE c.tr_id='S12344' and 
    ROWNUM <= (select (cast(a.create_time as date)-cast((select create_time from test b where a.tr_id=b.tr_id and code=1002) as date)) 
    from test a where a.code=1003 and a.tr_id=c.tr_id) + 1) d 
    WHERE to_char(cast((select create_time from test e where e.tr_id=d.tr_id and code=1002) as date) + RNUM - 1, 'DY') NOT IN('SUN');
    Need help to get the desired o/p

    Hello

    If I unederstand the problem correctly, that's what you want:

    WITH       got_extrema     AS
    (
         SELECT       tr_id
         ,       CAST (MIN (create_time) AS DATE)     AS start_date
         ,       CAST (MAX (create_time) AS DATE)     AS end_date
         FROM       test
         GROUP BY  tr_id
    )
    SELECT       tr_id
    ,       start_date, end_date          -- If wanted
    ,       24 * ( ( ( TRUNC (end_date,   'IW')          -- Count -1 day for every full week
                        - TRUNC (start_date, 'IW')
                 )
               / -7
                  )
                + LEAST ( end_date               -- If end_date is a Sunday
                            , TRUNC (end_date, 'IW') + 6     -- consider it 00:00:00 on Sunday
                     )
                - CASE
                          WHEN  start_date >= TRUNC (start_date, 'IW') + 6     -- If start_date is a Sunday
                   THEN  TRUNC (start_date, 'IW') + 6               -- consider it 00:00:00 Sunday
                   ELSE  start_date
                      END
                )     AS total_hours
    FROM      got_extrema
    ;
    

    I guess that you don't need to worry about fractions of a second. As you did in the code you have posted, I am to convert the TIMESTAMP to date values, because of DATE arithmetic and functions are so much better than what is available for timestamps.

    Basically, it's just to find the number of days between start_date and end_date and multiplying by 24, with these twists:
    (a) 1 day is deducted for each week between start_date and end_date
    (b) if End_date is a Sunday, none of the end_date himself hours are counted
    (c) If start_date is a Sunday, then all the start_date himself hours are counted. Why these hours should be counted? Because 1 day is already being deducted for the week which includes start_date, which contains only this Sunday.

    TRUNC (dt, 'IW') is the beginning of the ISO week containing dt; in other words, 00:00:00 the or before the dt last Monday. This is not the NLS parameters.

    Of course, I can't test without some sample data and the exact results you want from these data. You may need a little something more If start_date and end_date are both on the same Sunday.
    Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
    Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}

  • Difference between two dates

    Hello

    I have two columns both of them date data types.

    I would like to know the difference between these two dates.

    SELECTION INTERVAL ' + 2342 23:23:23 ' DAY (4) TO THE SECOND - INTERVAL ' + 102 13:13:13 ' DAY (4) SECOND FROM DUAL;

    But, I get this:

    '+ 2240 10:10:10.000000'

    I'd like to see the result in a year-month and jour-deuxieme groups. I can't do anything with + 2240 days...

    Thanks in advance!

    Hello Adme12

    You can use it.

    SET LINESIZE 110 PAGESIZE 20

    COLUMN today FORMAT A20

    COLUMN TOMORROW FORMAT A20

    COLUMN YEAR_MONTHS FORMAT A15

    COLUMN DAY_SEC FORMAT A30

    SET ECHO ON

    SELECT TO_CHAR (today, ' JJ.) MR. HH24:MI:SS' YYYY) LIKE TODAY

    , TO_CHAR (tomorrow, ' JJ.) MR. HH24:MI:SS' YYYY) TOMORROW

    NUMTOYMINTERVAL (MONTHS_BETWEEN (TOMORROW, TODAY), 'MONTHS') AS YEAR_MONTHS

    , NUMTODSINTERVAL (TOMORROW - ADD_MONTHS (TODAY, TRUNC (MONTHS_BETWEEN (TOMORROW, TODAY))), 'DAY') AS DAY_SEC

    Of

    (SELECT SYSDATE + INTERVAL ' + 102 13:13:13 ' DAY (4) ON THE SECOND THAT TODAY ' HUI)

    , SYSDATE + INTERVAL ' + 2342 23:23:23 ' DAY (4) ON THE SECOND TOMORROW

    OF THE DOUBLE

    )

    ;

    TODAY TOMORROW YEAR_MONTHS DAY_SEC

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

    23.04.2014 04:49 10.06.2020 14:59:10 + 000000006-02 + 000000018 10:10:10.000000000

    Of course, it is not so good that you have so many 0, but you can convert the result to a char (TO_CHAR) and you can enter.

    I hope this helps you!

    Kind regards

    David

Maybe you are looking for

  • M200: Lost Back Up DVD - how to install the OS?

    I have a M200 and have lost the backup DVD.My windows are confused, what is the best way to get that will once again without the backup DvD, or where I can get a copy of the DVD. Thank you.

  • Helix Gen 1: how to activate EUFI after new installation?

    I was sick and tired of the obscene amount of space the recovery partition took the my Helix and wanted a new 8.1 instead of an 8.0 upgrade facility. I had a lot of issues with my Helix of USB boot, until what the legacy BIOS setting. Once I deleted

  • Computer model of lens distortion

    Hi all When you calibrate the image on NI Vision Builder, I would like to ask what is the use of a "model of computing lens distortion. What is this for? It is an option that is ignored when measures are taken to the image, for example, of a componen

  • Windows 7 can download the same update

    I have recently updated of Vista to 7, and just like Vista, windows 7 keeps downloading and installing the update even. As soon as one is installed the same as is there to install. The update in question is updated with security update for Microsoft

  • Use Labview Timestamp in C++

    Hello I have to synchronize two software to 20 ms of precision, the timestamp of labview first single use (128bits, 1904 ect...) and cannot be changed. and the second is written in C++ using DAQmx, I find the trick of subtracting the number of second