Formula to calculate number of days between today's date & given date BEx

Hello,
I have a date available as an attribute of dimension characteristic. How do I get current date (sy-datum) to calculate the # of days (or difference) between query execution date and given date.
Is there a system field to get current or today's date .
I am thinking to have this as calculated KF in BEx.
Any suggestions or tips
Thanks

Hi,
Create a variable on the attribute(date attribute) of characterstic. Use this variable to create a formula variable , in which you fin out the difference between current date and varaible.
There  is a good document on using the attributes in the calculation in service.sap.com/bi
In infoindex--> calculation with attributes.
With rgds,
Anil Kumar Sharma .P

Similar Messages

  • Calculate number of days between two festival dates in payroll schema

    Hi Experts,
    According to my company policy:
    If an empl termination happens before Eid festival of the current year, then the pro-rated Eid bonus (yearly) is based on:
    (The duration between Eid Festival date of previous year - Eid festival date of current year.)/350 days
    Time Evaluation is not implemented in the system. Only payroll is implemented.
    My question: How can I capture the number of days between (Eid Festival date of previous year - Eid festival date of current year) in the payroll schema ?
    Regards,
    Somdeb.

    Hi,
    You can try using date specification. If you update last year eed holiday date for the employee then you can use the operand F along with NUM to get days between last eed holiday and current payroll period last day.
    i.e NUM=FaaT 0
    F is operand to query date specification.
    aa is the date specification.
    T is for unit and it gives number of days
    next space is for current payroll period last day and 0 will reset alternate date to zero if no date specification is mentioned.
    Basically this will give number of days from date mentioned in date type aa to current period last day. For more info you can go through documentation on operand F for NUM.
    Let us know if this helps.
    Regards,
    Poorvi.

  • How to calculate number of days between fixed date and hire date in schema

    i want to calculate the number of days between a fixed date en the hire date (infotype 041)
    If i read the documentation  right, i should use the following command:
    HRS=YDXA02
    Variable 3 (the x) is the fixed data.
    My question is how do i program the variable x?
    Let's say the date 01.01.2008
    Any help would be welcome

    I assume we are talking about PCR for payroll. In this case look at documentation for operation NUM:
    OOOOOO
    Xnnnnn
    X     Table
    nnnnn Table field
    nn    Date type 'nn' from the Date Specifications infotype (0041)
         Date types are taken from table T548Y.
    Your operation would look like:
      NUM=Faaesb
          F          Fixed indicator for deadline calculation
           aa           Date type: Start date of period to be
                        calculated; if the date type is not 'nn,'
                        the second position is left blank.
             e          Unit, in which the duration is calculated:
                        T = days
                        W = week
    s         End date of period to be calculated:
              (blank)  End of current payroll period
              J        End of current calendar year
              A        Start of current calendar year
              B        Start of WPBP period
             No other specifications are possible.
    So it depends on what kind of fixed date you need.
    Hope it helps,
    Carlos.

  • How to calculate number of days between Calendar objects

    Hi,
    I need to calculate the number of days between two Calendar objects. Here is some sample code:
    Calendar now = Calendar.getInstance();
    now.set(Calendar.HOUR_OF_DAY, 0);
    now.set(Calendar.MINUTE, 0);
    now.set(Calendar.SECOND, 0);
    now.set(Calendar.MILLISECOND, 0);
    // get a calendar that represents a day in the past
    Calendar aDayInThePast = getADayInThePast();
    aDayInThePast.set(Calendar.HOUR_OF_DAY, 0);
    aDayInThePast.set(Calendar.MINUTE, 0);
    aDayInThePast.set(Calendar.SECOND, 0);
    aDayInThePast.set(Calendar.MILLISECOND, 0);
    // how can I calculate the number of days ago this was??
    //it would also be useful to get back a negative number if the day is in the future

    My favorite answer so far is reply 15 by Marc__: http://forum.java.sun.com/thread.jspa?threadID=488668&start=15

  • How to calculate number of days between two date in Template design?

    Hello guys
    I have a situation where I have to create a template that returns data, and one of the thing of the existing report is that there is a column that is actually the number of days between start date and end date columns..
    So in template, how would I be able to do the same? I have start date and end date columns on the template, now when I created another column using expression like end date - start date and preview the template, I am getting errors saying :
    Caused by: oracle.xdo.parser.v2.XPathException: Cannot convert 03/31/2009 to number.
         at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1534)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:521)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:489)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:271)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:155)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:192)
    Please advice
    Thanks

    Hi
    There is an extension function you can use, from the javadoc:
    date_diff
    public static long date_diff(java.lang.String format,
    java.lang.String fromDate,
    java.lang.String toDate,
    java.lang.String locStr,
    java.lang.String tzID)
    Method to get the difference between two dates in the given locale. The dates need to be in "yyyy-MM-dd" format. This function supports only Gregorian calendar.
    Parameters:
    format - the format to which the difference is required; allowed formats are y (for Year), m(for month), w(for week), d(for day), h(for hour), mi(for minute), s(for seconds) and ms(for milliseconds)
    fromDate - the first date
    toDate - the second date
    locStr - locale string -> lang-Territory
    tzID - timezone ID ->http://java.sun.com/j2se/1.4.2/docs/api/java/util/TimeZone.html
    Returns:
    the difference in dates in the desired format
    For example
    <?xdoxslt:date_diff(‘d’,’2009-09-14’, ‘2009-09-20’,’en-US’,1)?>
    give a result of 6
    You can substitute in columns for the dates, just remember the date format required.
    Regards
    Tim

  • Confused - How to Calculate Number of Days Between Dates but Exclude Weekend Dates If There Hasn't Been a Weekend Update

    Hello -
    I've been tearing my hair out over this problem i'm trying to solve, probably just been staring at it too long which is making it worse -
    I have a series of open support tickets which are supposed to be updated on a daily basis, the problem is that they aren't always being updated daily.  So, the business wants to know the number of days from when a ticket was last updated and today's
    date.  I have this basic calculation and it's working fine, however now the business wants to exclude weekends from the calculation.  The other problem is that some reps DO go in on weekends and update their tickets, so sometimes there will be updates
    made on weekend dates.
    To give an example -
    Today's date is 2014-02-10 (Monday).  A ticket was last updated last Thursday, 2014-01-30.  The difference between the two dates is 11, so it's been 11 days since the ticket was last updated.  Now, if I exclude Saturdays and Sundays, then
    it's actually been 7 days since the ticket was last updated.  I'm not sure how to do this in T-SQL.
    Now, to further complicate the problem, sometimes a ticket IS updated on a Saturday or Sunday.  So, if a ticket was updated on 2014-02-02 (Sunday), then it should be counted.  Again i'm not sure how to do this. 
    What gets me is that this is probably fairly simple and i've just been staring at it too long.  In the meantime, can someone offer some guidance?
    Thanks!!

    I've adapted this from a function on my blog. you will need to add set the YourTicketTable to where ever your tickets are stored.
    CREATE
    FUNCTION [dbo].[CalcWorkDaysBetween](@StartDate
    As DateTime,@EndDate
    AS DateTime)
    RETURNS
    INT AS
    BEGIN
    SET @EndDate
    =DATEADD(DAY,1,@EndDate)
    DECLARE @Count
    AS Int= 0
    DECLARE @Date
    As Date=@StartDate
    WHILE @Date
    < @EndDate
    BEGIN
    IF (DATEPART(WEEKDAY,@Date)IN(1,7)
    OR (SELECT
    Count(*)
    FROM YourTicketTable WHERE TicketDate=@Date)=1)
    BEGIN
    SELECT @Count = @Count
    + 1
    END
    SELECT @Date=DATEADD(Day,
    1,@Date)
    END
    RETURN
    DATEDIFF(DAY,@StartDate,@EndDate)- @Count
    END
    Regards,

  • Calculate number of days based on System Date and a date column!

    Hi everyone,
    I have a query to run a report where the results has a column named “Due Date” which holds a date value based on the project submission date.
    Now, I need to add 4 columns named, “45 Days Expectant”, “30 Days Overdue”, “60 Days Overdue” and “90 Days Overdue”.
    I need to do a calculation based on the “Due Date” and “System (I mean default computer date) Date” that if “System Date” is 45 days+ to “Due Date” than put “Yes” in “45 Days Expectant” row.
    Also, if “Due Date” is less than or equal to system date by 30 days, put “Yes” in “30 Days Overdue” and same for the 60 and 90 days.
    For example the output should be like:
    Is this possible? Can someone help me how to write this Case Statement please? I have some answers how to do it in SSRS (Report Designer) but I want to get the results using T-SQL...Thanks heaps...cheers...
    artistdedigital

    Hi Jay,
    Thanks but those dates are just a reference. The actual table contains hundreds of date rows... so I guess this technique will not work (not sure though)...
    I am quite cool with this bit:
    select duedate,
    case when days > -45 and days < 0 then 'YES' else '' end as '45 Days Expectant',
    case when days between 30 and 60 then 'YES' else '' end as '30 Days overdue',
    case when days between 60 and 90 then 'YES' else '' end as '60 Days overdue',
    case when days > 90 then 'YES' else '' end as '90 Days overdue'
    from cte--------------------------------------------------------------------------------------------------But can you please explain this bit a more? Thanks for being so prompt though : )declare @tab table (duedate datetime)
    insert @tab select '04/25/2014'
    insert @tab select '02/10/2014'
    insert @tab select '01/10/2014'
    insert @tab select '12/10/2013'
    ;with cte
    as
    select duedate,datediff(dd,duedate,getdate()) as days
    from @tab
    artistdedigital

  • Number of days between to dates

    Hello to all,
    I would like to define a formula to calculate number of days between two dates and update the value in a key figure.
    *operand: {Name of keyfigure,Fecha ini (Mes/Año),Fecha Fin (Mes/Año)}
    DATA FECHAINI  TYPE ZIOV_FEIN.
    DATA FECHAFIN TYPE ZIOV_FFIM.
    DATA INI             TYPE 0CALMONTH.
    DATA FIN            TYPE 0CALMONTH.
    DATA DIA_INI      TYPE D.
    DATA DIA_FIN     TYPE D.
    DATA DIAS          TYPE F.
    FOREACH FECHAINI, FECHAFIN.
      INI = FECHAINI.
      FIN = FECHAFIN.
    *C2DATE Determine end period date
      DIA_INI = C2DATE(INI, E).
      DIA_FIN = C2DATE(FIN, E).
      DIAS = DIA_FIN - DIA_INI.
    {ZIOV_DIAS,FECHAINI,FECHAFIN} = DIAS.
    ENDFOR.
    Problem: UPF057 type F conflicts with type D. 
    Help would be much appreciated.
    Regards,
    Patrícia

    The function is built in:
    CALL METHOD CL_RSAR_FUNCTION=>DATE_DIFF(
      EXPORTING I_DATE_1 = L_ARG2
                I_DATE_2 = L_ARG3
      IMPORTING E_RESULT = L_ARG1  )

  • Find Exact number of days between two dates

    How can get the exact number of days between two dates?

    An example of business days calculation in SQL */
    /* The algorythm is: */
    /* 1) Take the absolute difference between the dates */
    /* to_date('&todate') - to_date('&frdate') */
    /* 2) Subtract the weekends (number of weeks in the range */
    /* TRUNC(to_date('&todate'),'D') = 1st day of week that */
    /* end of period is in */
    /* TRUNC(to_date('&frdate'),'D') = Last day of week that */
    /* start of period is in */
    /* So subtracting these two gives the number of days */
    /* between the two dates but including all of the days in */
    /* the weeks that the dates start and end in. When this */
    /* number is divided by 7 it gives the number of weeks. */
    /* Multiplying by 2 gives the number of weekend days.     */
    /* 3) Subtract 1 day if the ending date is on a saturday */
    /* DECODE(to_char(to_date('&todate'),'D'),7,-1,0) */
    /* --> If the day of the week is saturday (7), returns -1 */
    /* 4) Subtract 1 day if the start date is on a sunday */
    /* DECODE(to_char(to_date('&frdate'),'D'),1,-1) */
    /* --> If the day of the week is sunday (1), returns 1 */
    /* 5) Add one day to make the range inclusive (The '1 + ' ) */
    /* Author: Kenneth Atkins ([email protected]) */
    /* http://www.olywa.net/katkins/oratip */
    define frdate = '&1'
    define todate = '&2'
    set verify off
    select      
         '&frdate' From_Date
         ,'&todate' To_Date,
         1 + to_date('&todate') - to_date('&frdate') -
         ((TRUNC(to_date('&todate'),'D') - TRUNC(to_date('&frdate'),'D'))/7)*2
         + DECODE(to_char(to_date('&todate'),'D'),7,-1,0)
    + DECODE(to_char(to_date('&frdate'),'D'),1,-1,0) Business_Days
    from dual
    Here is an example of running the script:
    SQL> @busdays 01-AUG-96 15-AUG-96
    FROM_DATE TO_DATE BUSINESS_DAYS
    01-AUG-96 15-AUG-96 11

  • Calculate the days between today and specific day.

    I'm trying to calculate the number days between Today and some specific date in the future using SharPoint Designer (XSL). This is what I'm using:
    <xsl:value-of select="number(ddwrt:DateTimeTick(ddwrt:GenDisplayName(string(@Due_Date))))- number(ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($Today))))" />
    e.g. 23 days >>>> 634948416000000000 ticks
    This works perfectly while I'm in SPDesigner itself, but once I try to see it in the browser it shows the number of days in "Tick Numbers". Is there a way I can fix this? I've been looking all over the internet and I haven't found any really good answer.
    thanks!

    Thanks for the quick response Marc.
    I've no experience of using momentsJs with SharePoint lists and I need to be able to get this up and running pretty quickly. I guess you need some coding experience to use it?
    I'm thinking that there should be a way to do this in SPD with something similar to this from another site, but with the conditions placed on the source field (Planned end Date)  instead of the current date. 
    not((ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($thisNode/@Plan_x0020_Ende)))
    >=
    (ddwrt:DateTimeTick(ddwrt:Today())-(7*24*60*60*1000*10000)))
        and
    (ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($thisNode/@Plan_x0020_Ende)))
    <=
    (ddwrt:DateTimeTick(ddwrt:Today())+(7*24*60*60*1000*10000))))
    and
    not((ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($thisNode/@Ist_x0020_Ende)))
    >=
    (ddwrt:DateTimeTick(ddwrt:Today())-(7*24*60*60*1000*10000)))
        and
    (ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($thisNode/@Ist_x0020_Ende)))
    <=
    (ddwrt:DateTimeTick(ddwrt:Today())+(7*24*60*60*1000*10000))))

  • How can I calculate the maximum number of days between two dates in a range of dates?

    I have a column of dates spanning the couse of a few months.  I would like to know if I can calculate the maximum number of days between each row and display the highest number.  I currently have another column that calculates the days betwen the rows and I am currently just looking at the totals and highlighting the highest period.
    Is this possible?  Any help or suggestions are appreciated.
    Thank you,
    Trevor

    This sounds totally possible,  Can you post a screen shot of your table to make responding more focused?  If you mean you want to:
    A) compute the difference (in days) between two date in the same row, then
    B) find the max duration (in days)
    Here is my take on this problem:
    D2 = C2-B2
    select D2 and fill down
    F1=MAX(D)
    to perform the conditional formatting (to highlight the max duration) select column D, then set up conditional formatting as shown in the 1st image

  • I wanted to know how do you calculate the number of days between two dates

    i wanted to know how do you calculate the number of days between two dates in java ? i get both the dates from the database. i guess there are many issues like leap year and Febuary having diff no of months ..etc.

    thanks..
    I solve my problem as
    public class MyExample {
        public static void main(String a[]) {
            String stdate = "2009-03-01";
            java.sql.Date currentDate = new java.sql.Date(System.currentTimeMillis());
            java.sql.Date preDate = java.sql.Date.valueOf(stdate);
            System.out.println(currentDate);
            System.out.println(preDate);
    //        int dateCom = preDate.compareTo(currentDate);
    //        System.out.println(dateCom);
            long diff = currentDate.getTime() - preDate.getTime();
            int days = (int) Math.floor(diff / (24 * 60 * 60 * 1000));
             System.out.println(days);
    }

  • Getting number of days between 2 dates

    Hello All,
    I require the number of days between 2 dates.
    The number of days is between low date : PR Date (not an input variable) and the high date.
    I have created an customer exit variable to get sy-datum in made it as formula variable.
    I have also created a formula variable for PR Date , and subtracted the 2 dates.
    It is not giving the correct result.
    Any suggestions.
    Thanks & Regards,
    VL

    Read through this web link.  It will show you how to calculate the days between 2 dates directly in your BEX query.
    No exit needed to calculate this.
    http://teklink.co.uk/sap/sap-bi-bw-how-to-use-replacement-path-variables-to-perform-date-calculations-in-the-bex-analyzer/

  • How to calculate number of days in ABAP?

    Hi,
    I have a condition as below:
    If (field1 - field2) > 12 Months
    E.g field1 = 31.05.2011 & field2 = 10.11.2011
    Can SAP actually minus dates and check if the difference is greater than 12 months?
    How do I perform this calculation?
    Pls advice.
    Thanks!
    Moderator message : Date FAQ, duplicate post.  Thread locked.
    Edited by: Vinod Kumar on Mar 2, 2012 1:50 PM

    Hi,
    If your calculating dates please do not manually calculate it like that.
    You need to determine like week numbers, month and days.
    The best way to do it is by using FM related to dates. Play around with these FMs in your program:
    Function Modules related to Date and Time Calculations
    CALCULATE_DATE  - Calculates the future date based on the input .
    DATE_TO_DAY - Returns the Day for the entered date. 
    DATE_COMPUTE_DAY - Returns weekday for a date
    DATE_GET_WEEK - Returns week for a date
    RP_CALC_DATE_IN_INTERVAL - Add days / months to a date
    DAY_ATTRIBUTES_GET - Returns attributes for a range of dates specified
    MONTHS_BETWEEN_TWO_DATES - To get the number of months between the two dates.
    END_OF_MONTH_DETERMINE_2 - Determines the End of a Month.
    HR_HK_DIFF_BT_2_DATES -Find the difference between two dates in years, months and days.
    FIMA_DAYS_AND_MONTHS_AND_YEARS - Find the difference between two dates in years, months and days.
    WEEK_GET_FIRST_DAY - Get the first day of the week
    SD_CALC_DURATION_FROM_DATETIME - Find the difference between two date/time and report the difference in hours
    L_MC_TIME_DIFFERENCE - Find the time difference between two date/time
    HR_99S_INTERVAL_BETWEEN_DATES - Difference between two dates in days, weeks, months
    LAST_DAY_OF_MONTHS - Returns the last day of the month
    DATE_CHECK_PLAUSIBILITY - Check for the invalid date.
    DATE_2D_TO_4D_CONVERSION - Year entry: 2-character to  4-character.
    DAY_IN_WEEK  - Input date and will give the name of the day 1-monday,2-Tuesday....
    SD_DATETIME_DIFFERENCE - Give the difference in Days and Time for 2 dates

  • How to calculate number of days in hijri

    Dear all,
    I need to develop a custom report in which i required to calculate number of days in hijri month and also the first and last day of the hijri month. we normally use Last_date(sysdate) function to get the last date of the english calender. but how can we find same for month.
    Looking after for your support.
    Regards,
    Saquib

    Convert to hirjih date using:
    select
    to_char(sysdate,'YYYY/MM/DD','NLS_CALENDAR=''English Hijrah''') hijrih_date
    from dual;
    You can replace sysdate with the date of your choice.
    Also I wrote this for my last project:
    /* get hirjih date */
    FUNCTION get_hijrah_date(
    p_date in date,
    p_date_format in varchar2
    ) return varchar2
    is
    v_hijrah_date varchar2(500);
    begin
    select
    to_char(p_date,p_date_format,'NLS_CALENDAR=''English Hijrah''')
    into v_hijrah_date
    from dual;
    return v_hijrah_date;
    end get_hijrah_date;
    So you can have get_hijrah_date(sysdate,'DD-MON-YYYY') from dual;
    (or any other date formate of your choice)
    Edited by: igwe on Jan 30, 2013 8:07 AM

Maybe you are looking for