How to calculate the number of days/weeks/months between 2 dates?

Hello

I would like to know how to calculate the number of days/weeks/months between 2 dates in OBIEE 11 g, for example, I have 26/05/2013 and 19/05/2013, then I want to get 7 days.

Thank you!
Jamie

Hi Jamie,

Through this links...

http://www.bravesoft.com/blog/?p=682
http://twobiee.blogspot.in/2012/01/working-with-date-differences.html

Mark as correct it allows u...
Thank you...

Tags: Business Intelligence

Similar Questions

  • How to calculate the number of days between dates

    How can I determine the number of days between 2 dates? Say today and 10/07/46

    Thanks Bob

    You could do it like this:

    Photoperiod var = 1000 * 60 * 60 24; number of ms in a day

    var today: Date = new Date();

    var every time that: Date = new Date (1946,6,10);

    var diff = Math.floor((today.getTime()-whenever.getTime())/dayLength);

    trace (diff)

  • How to get the number of days

    Hai bloggers,
    See us have 365 days a year for all first half we'll have 180 + days (if we choose first half as the guest and we select week as guest number and the last date of this particular week must indicate in the report) and the number of days until this date or a week should also display... If we choose the second half and half week number it should show number of days until this week and more Date of this issue of the day week should be from 1 to 180 + only way (July 1 m is 1)

    Thank you

    You must use the timestampdiff function to calculate the number of days. One of the way to calculate is how

    cases where "Time". "" Calendar semester "= 1 then timestampdiff (SQL_TSI_DAY, CAST (EVALUATE ('TO_DATE (%1, %2)','' 01-01 |' @{YEAR} {2010}',"DD-MM-YYYY") AS DATE), cast OFF (EVALUATE ('TO_DATE' (1%, 2%), 30-06' |' @{YEAR} {2010}',"DD-MM-YYYY") AS DATE)) else timestampdiff (SQL_TSI_DAY, MOUNT (EVALUATE ('TO_DATE (%1, %2)','01-07' |' @{YEAR} {2010}',"DD-MM-YYYY") AS DATE), cast OFF (EVALUATE ('TO_DATE' (1%, 2%),' 31-12 |' @{YEAR} {2010}',"DD-MM-YYYY") AS DATE)) end

    If you want to calculate between the 1st day of the half and the last date a week then after

    cases where "Time". ' ' Calendar semester ' = 1 then timestampdiff (SQL_TSI_DAY, CAST (EVALUATE ('TO_DATE (%1, %2)','01-01' |' @{YEAR} {2010}', 'DD-MM-YYYY') AS DATE), MAX (MAX ("Time".) "Calendar Date"))) else timestampdiff (SQL_TSI_DAY, CAST (EVALUATE ('TO_DATE (%1, %2)','01-07' |' @{YEAR} {2010}', 'DD-MM-YYYY') AS the DATE), MAX (MAX ("Time".) " End Calendar Date")))

    Hope that it will answer your question

    Thank you
    Phani.

  • Calculate the number of days remaining until the next anniversary. Help, please!

    Hi guys,.

    I'm new to the forum and to the development of BB. So please do not judge harshly if the answer to my question seems obvious.

    I need to calculate the number of days until the next birthday (taking into account any valid birth date)

    After looking at the API and the forum search, I realized that I could

    calculate the difference between two dates in milliseconds and then divide the delta of the value of a day in milliseconds. That is to say:

    birthdayCalendar.set (Calendar.YEAR, those);

    Date1 = birthdayCalendar.getTime () .getTime ();

    date2 = System.currentTimeMillis ();

    Delta = date1 - date2

    numOfDays = delta\DateTimeUtilities.ONEDAY

    Here's my question. How do I create a valid date1 what about leap years?

    Maybe there's a better way to solve this problem?

    Any help is greatly appreciated.

    I agree that the determination of the number of days between today and Feb. 29 could be a little difficult, if it is not a leap year.  I suspect that the calendar has a certain built-in mechanism to compensate for this, but your solution to choose a date is better.

    DST has a role to play, and Yes, the calendar makes up for it.  Let us take two dates, for example (before DST) March 1 and June 1 (after the DST).  If you take a calendar and set the same hour, minute, etc., they are all the same except for dates, then subtract one from the other, and then divide by the number of milliseconds in 1 hour, you calculate the number of hours between the same time on two different days.  You will find that it is not a multiple of 24 hours - because there is actually an hour less than the number of days since the clocks move forward (in the northern hemisphere anyway...),

    In your case, you are not calculating the number of hours, you calculate the number of days.  But you will be dividing by [24 * (time in an hour)].  If you take [23 * (time in an hour)] and divide it by [24 * (time in an hour)], using arithmetic on integers, you will end up 0.  The easiest to get around this, who also works for the end of the DST too, is to simply add one hour to the date before the division.

    Hope that makes sense...

  • How to find the number of days between 2 date elements in the XSLT file

    Hello

    I need to calculate the number of days between 2 date elements (type xs: date). Can you please direct me as to how I can do the same thing.

    I work in 11g and using XSLT 1.0. I tried several options but yet to get a solution for this. I think that this can be done also using XSLT 2.0, but who has not worked for me.

    Can someone please help with this problem, thanks in advance!

    Thank you
    Anju

    Hello

    Have you seen this message?
    Re: Get the Date difference between 2 values of date in days

    You can do in the XSLT file since the dates are in ISO 8601 format.
    http://www.w3.org/TR/NOTE-datetime

    Here is a sample XSLT...

    
    
    
    
    
    
    
    

    The XSLT above will result in * 4 * for the next entry...

    
    2012-01-11T00:00:00.000-05:00
    2012-01-15T00:00:00.000-05:00
    
    

    You can test this example here...
    http://xslttest.appspot.com/

    I hope this helps...

    See you soon,.
    Vlad

    It is considered good etiquette to the answerers rewards with points (as "useful" - 5 pts - or 'correct' - 10pts)
    https://forums.Oracle.com/forums/Ann.jspa?annID=893

  • to calculate the number of days between 2 dates

    Hi all


    I need to calculate the number of days between 2 dates.
    Y at - it no oracle built on that basis.



    Thanks in advance
    Kind regards

    Nick

    user646786 wrote:
    Hello

    Thanks a lot its really useful, but I must make a correction, I just want weekdays rather working days

    As already said, there are many examples on the forum of the calculation of the working days or the days of the week or whatever you want between certain dates of restrictions. You will need to have a go at adapting what has already been given before and then when you get stuck, come here and your postcode, and someone will take a look for you.

  • How to calculate the number of Out_flags for the PIPL?

    Hey everybody!

    I'm kinda new to After Effects of programming, so I hope I'm not asking an obvious question.

    I searched the web and this forum but just could not find a solution to this problem.

    Compilation of my plugin works fine, but as soon as I select it from the menu effects I am presented with an incompatibility error.

    My question (already in the title): how to calculate the correct number for the global_out_flags pipl?

    Thanks in advance,

    Markus

    If you want the easiest option, just start with the debugger and to break in the General preferences where is defined, or, if you find amusement in the bit and other Boolean arithmetic shift, please do not hesitate to look at the macro

  • Calculate the number of days between two dates

    Hello

    Can someone help please change my formcalc script to calculate the number of working days between two date fields.  My script currently calculates the total number of days between two dates, including the weekends which must be excluded from the total.

    If

    (HasValue (Start_Date1) & HasValue (End_Date1)) then

    $

    = Date2Num (End_Date1, "YYYY-MM-DD" "en_IE") - Date2Num (Start_Date1, "YYYY-MM-DD" "en_IE") + 1

    on the other

    ""

    endif

    Any help will be most appreciated.

    Thank you.

    Check...

    (1) you said that you put the script on the event «days1» calculate My sample imitates the variable names used in the original message, "Start_Date1" and "End_Date1". If the names of variables for the start and end dates are different, you will need to modify the script to account for these names.

    (2) the Date2Num functions in the calculation of the "totalDays" use the date format "YYYY-MM-DD". If your date habits differ from "YYYY-MM-DD" FormCalc will complain.

    Steve

  • How to increase the number of days before deleting messages in the trash?

    The automatic removal of e-mails to the trash is set for about 3 days. Much too short an e-mail should be necessary.

    In the left column of the files right click Trash. Select them properties. Click on the retention policy tab. Uncheck the box if it is enabled. Select the number of days you want to keep before deleting.

  • How to get the number of days in a month of belonging to a range of dates

    Hi, I'm going crazy around a problem, I have 2 dates and one month I wanto to retrieve the number of days belonging to the months that fall within the range.

    for example:

    month of January 2011. begin_date = January 11, 2011, May 30, 2011 end_date result is 21
    month of January 2011. begin_date = December 11, 2010, result of end_date, January 10, 2011 10
    month January 2011 .begin_date = 2 February 2011, end_date may 25, 2011 result 0
    month of January 2011. begin_date = January 3, 2011, January 5, 2011 result DATE END 3

    and so on...

    I appreciate any suggestion
    Thank you


    Andrea

    Something like that... ?

    SQL> with t as
      2  (select  to_date('11/01/11','dd/mm/yy') from_dt,
      3           to_date('30/05/11','dd/mm/yy') to_dt,
      4           'Jan-11' mnth from dual)
      5  select least(last_day(to_date(mnth,'Mon-yy')),to_dt) -
      6         greatest(to_date(mnth,'Mon-yy'),from_dt) cnt
      7  from t  ;
    
           CNT
    ----------
            20
    

    If 0 is also expected...

    SQL> with t as
      2  (select  to_date('11/01/11','dd/mm/yy') from_dt,
      3           to_date('30/05/11','dd/mm/yy') to_dt,
      4           'Jan-11' mnth from dual union all
      5           select  to_date('11/01/11','dd/mm/yy') from_dt,
      6           to_date('30/05/11','dd/mm/yy') to_dt,
      7           'Jan-12' mnth from dual
      8           )
      9  select from_dt,to_dt,mnth,
     10         greatest(
     11              least(last_day(to_date(mnth,'Mon-yy')),to_dt)
     12              -
     13              greatest(to_date(mnth,'Mon-yy'),from_dt)
     14                 ,0) cnt
     15  from t;
    
    FROM_DT   TO_DT     MNTH          CNT
    --------- --------- ------ ----------
    11-JAN-11 30-MAY-11 Jan-11         20
    11-JAN-11 30-MAY-11 Jan-12          0
    

    Published by: JAC on February 9, 2012 19:22

  • Dynamically calculate the number of days between two dates and amounts of split

    Hello

    I have searched for a solution for this, but had no success.
    I need to show the amounts broken down by days.

    I have a table that has an amount column and start and end dates.

    I need to write a query so that the amounts will be broken evenly based on the number of days between the start date and end date.

    For example, for this line.
    insert into my_test values (' 1, '' 3-mar-2010, ' 7 - mar - 2010 ", 1000);

    the query returns this (split $1,000 over 5 days)


    ID Date amount
    1 ' 3-mar-2010' 200,00
    1 ' 4-mar-2010' 200,00
    1 ' 5-mar-2010' 200,00
    1 ' 6-mar-2010' 200,00
    1 ' 7-mar-2010' 200,00



    create table my_test)
    ID number (10),
    start_date date,
    End_date date,
    amount number (10.2)
    );


    Select * from my_test

    insert into my_test values (' 1, '' 3-mar-2010, ' 7 - mar - 2010 ", 1000);
    insert into my_test values (2, 10-mar-2010 ", 19-mar-2010", 2000);
    insert into my_test values (3, 20-mar-2010 ',' 21-mar-2010, 5000);



    Thanks in advance.

    Hello

    One way is to join a Meter of Table , a table, or (more often) a set of results includes a line for eery number 1, 2, 3,... until the maximum number of times you need to divide a line.
    For example:

    WITH     cntr     AS
    (
         SELECT     LEVEL - 1     AS n
         FROM     (  SELECT  MAX (end_date - start_date)     AS max_day_cnt
                 FROM        my_test
              )
         CONNECT BY     LEVEL <= 1 + max_day_cnt
    )
    SELECT       t.id
    ,       t.start_date + c.n                    AS dt
    ,       t.amount / (t.end_date + 1 - t.start_date)     AS amt
    FROM       my_test      t
    JOIN       cntr            c     ON     c.n <= t.end_date - t.start_date
    ORDER BY  id
    ,            dt
    ;
    

    This assumes that all dates have the same number of hours, minutes, and seconds, as is the case in your sample data.
    If this isn't the case, then use TRUNC (start_date) and TRUNC (end_date) instead of start_date and end_date or post some sample data and results if some lines do not represent a whole number of days.

  • How to retrieve the number of days of a number

    Hi everyone, from X number, I need to retrieve the number of days.
    For example:

    X = 10-number of days > = 0
    X = 12-number of days > = 0.5
    X = 24-number of days > = 1
    X = 25-number of days > = 1
    X = 34-number of days > = 1
    X = 36-number of days > = 1.5
    X = 37-number of days > = 2
    X = 72-number of days > = 3
    X = 70-number of days > = 3

    I tried with Round, but it did not work as I wanted, because with 36 he recover 2 (instead of 1.5).
    In practice, a half day (12 hours) must be ALWAYS considered 0.5 and unrounded.

    Any idea?
    Thanks in advance

    Alex
    WITH T AS (SELECT 10 X FROM DUAL UNION ALL
            SELECT 12 FROM DUAL UNION ALL
            SELECT 24  FROM DUAL UNION ALL
            SELECT 25 FROM DUAL UNION ALL
            SELECT 34 FROM DUAL UNION ALL
            SELECT 36 FROM DUAL UNION ALL
            SELECT 37 FROM DUAL UNION ALL
            SELECT 72 FROM DUAL UNION ALL
            SELECT 70 FROM DUAL)
    SELECT X, DECODE( MOD(X/24, 1), 0.5, X/24, ROUND(X/24))
    FROM T
    
  • calculate the number of days excluding non-working days

    11.2.0.4

    theres a fairly common request over the years to get the diff between 2 dates, excluding weekends, theres many ways to to do, however, I would like to go a step further and exclude everything not professional

    day.

    We have a company function that calculates whether a date is a holiday for our Organization.  We can pass a date and we have a Y or N back.     In the example below, the l' appel call function shows there for Saturday to show how we can identify the non-working day.

    Can anyone think of a way that we could use to get a sum of N s between 2 date fields in a line using this function?   IM thinking if we get the right formula/function to create a virtual column with calculating pre built as it can start to get expensive if she had to loop through every possible day between 2 dates to see it is a business day, all by a count.

    create the table t1_count

    (identification number,

    date of TS1,

    date of TS2)

    insert into t1_Count

    values (1, sysdate, sysdate - 7);

    insert into t1_Count

    values (2, sysdate, sysdate - 4);    -Saturday

    commit;

    SELECT id, ts1 ts2, .isholiday (ts1), isholiday (ts2) of t1_count;

    106/03/2015-14:30:5127/05/2015 14:30:51NN
    106/03/2015-14:32:2930/05/2015 14:32:29NTHERE

    That fold to my brain...

    ABS (trunc (sysdate - 40) + level - 1 - trunc (sysdate)) that's equivalent to the abs (level - 41)...

    Why not just level<=>

  • Calculate the number of days off weekends


    Hi all

    I have a requirement where I have to calculate the difference between two dates, excluding weekends and holidays. Is there a way I can do it in OBIEE analysis.

    Any help would be appreciated.

    Thanks in advance!

    Check it for weekends cool - bi.com

    For the holidays, you will need to customize you the size of the day

    check if help

  • How to calculate the number of Avg based on month

    Hi all

    I want to calculate Avg based on averages of the month

    Ex: i have made Total column
    current month like July Thn avg = total/7.
    then even report working in October than avg time = total/10.

    Any help.

    Thank you

    You must specify a digital for parameter 2. The Substring function takes the source from character string parameters and the length of the unit. In my example it will take the value of the variable current_month and returns the characters of the 8th position for 2 characters (so character 8 and 9). For example, instead of 'Time' happening. "" Month "you must pass the literal number 8. So I think the actual code you need is:

    SELECT "Applications and financial accounts. "" Value "/ CAST (SUBSTRING (VALUEOF ("CURRENT_MONTH") OF 8 TO 2) as INT)"financial accounts and Applications.

    NB I'm assuming that the value that you want to divide by the number of current month is called "Applications and financial accounts. "" Value ", please change it's column that you never use.

    Please mark it as useful to the answer

Maybe you are looking for

  • Satellite P100-426: Windows Mobile Device Center cannot find my BT device

    Hello Why Windows Mobile Device Center can't find my device Bluetooth (although that my bluetooth works properly)? I have a Toshiba Satellite P100-426, with a built in Bluetooth device Sascha

  • Satellite L30 (PSL33E) - upgrade of CPU and RAM

    For all other owners L30, my L30 - 10 v has been improved by me to the following specification while I owned it: Intel Core Duo T2450 bus of 2 GHz 533 mhz cpu (faster processor you can use in the L30 psl33e)2 GB DDR2 667 mhz Ram (1 x 1 GB Kingston, 1

  • Need some drivers for my Satellite A100

    Dear all, Could someone help me? I bought my laptop (Satellite A100, PSAA9) with XP 2007 April.Yet I have installed the Microsoft Windows Vista Ultimate 32-bit OS (with SP1) Vista has found a lot of drivers for my laptop, but someone is missing.For e

  • Structure of the event within the structure of the case run once

    Hi all I am a controller using myRIO and labview where the program compares a value of the probe in a "Preset" and then choose a structure case depending on what type of air supply is required. What can be seen on the picture, for example, is 0 if sa

  • Access (which is not control or indicator) in another structure of matter

    Hi all Description of the problem: I have a mutli-dimensional array, named 'Micro Channel Array', where I am retrieving values of 'Channels' field and insert a label table: "insert the channel into Array. It works very well. Now, I want to use this t