Substracting number of days from date

Hi all, I need to create a user exit to get a date value based on another variable. Basically, 100 days minus the first variable.
var2 = var1 - 100
How can I write this?
Thanks.

Ok, I figured it out. I had to declare variables of type d and then assign it.
IF i_step = 2.
    data:zday type d,
          zday1 type d.
*****Loops for Variable.*****************************************
    LOOP AT I_T_var_range
         INTO loc_var_range WHERE
                  VNAM = 'ZENDT' or
                  VNAM = 'ZENDATE'.
    zday = loc_var_range-low.
    zday1 = zday - 275.
*      l_S_range-low = loc_var_range-low - 275.
      l_S_range-low = zday1.
      l_s_range-sign = 'I'.
      l_s_range-opt = 'EQ'.
      APPEND l_s_range TO E_T_range.
    ENDLOOP.
    EXIT.
  ENDIF.

Similar Messages

  • Customer Exit for Number of Days from 1 st Apr to last date of Month Enter

    Hello BI Experts,
    I have a requirement to count the number of days from 1 st April of current year to the last date of month entered.
    For example : The use will enter say July 2010 or 003.2010  (as Fiscal Year Variant is V3 ).
    Today is 14 July ...So we have to first find out the end date of the July month ie 31 st July
    Then go to 1 st April 2010.
    Now calculate the Number of days between 1 st April to 31 st July 2010.
    I consider I have to create two Customer Exit variable
    as below
    1 st customer exit Bex variable  say  ZLY_MTH  ( Last day of Month Entered)
      and i_step = 1
    2 nd Customer Exit BEx Formula variable say ZF_NUMDAYS ( Number of days between two dates)
    i_step =1 .
    Please provide me the logic for the above two.
    Thanks in Advance.
    Regards,
    Amol Kulkarni

    PSUDEO CODE:
    1. Initially LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'ZMONTH'.
    2. Get the Month input using VAR_MONTH2 = LOC_VAR_RANGE-LOW+4(2)
    3. Now calculate Month+1: VAR_MONTH2 = VAR_MONTH2 + 1 (Refer **)
    4. Now calculate the Current Year: VAR_YEAR = LOC_VAR_RANGE-LOW+0(4).
    5. Get the 1st Day of the Month (VAR_MONTH2):  CONCATENATE '01' '/' VAR_MONTH2 '/' VAR_YEAR INTO L_S_RANGE-LOW.
    6. SUBRACT 1 (0DATE) from this DATE (This will give the logic for last day of the current month)
    Insert this code also for using the date conversions
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                INPUT  = VAR_MONTH2
              IMPORTING
                OUTPUT = VAR_MONTH2.
    Pls. check out this logic. Guess it would solve your need.
    Thanks,
    Arun Bala

  • How to calculate number of days from a date field

    Dear BW Experts.
    I have a field 'Create Date' in the BEx query. Now we need to create a variable which should give the number of days from the date of running the query (sy-datum) to the Create Date.
    This will help the users to get records which are say, 30 days old (Sy-datum - create date = 30) or 10 days old etc.
    Could you suggest as to how to create this variable.
    Thanks,
    Sai

    Hi,
    Step 1: Create variable on "Create Date" with User entry processing type
    Step 2: Create a restricted KF for Sales & restrict it on "Create Date" to get "Sales on day"
    Step 3: Manipulate  the values of "Create Date" on which you could restrict  "Sales" again and again to get other values
    Step 4: Create one variable (ZPUTMNTH) for u201CMonth to Dateu201D with processing by u201CCustomer Exitu201D. This variable was created  on u201CDateu201D characteristics.
    Step 5 : Goto C-mod t-code and use EXIT_SAPLRRS0_001
    to calculate "month to date" user input is "Calday" Key Date
    WHEN 'ZPUTMNTH'.
    IF I_STEP = 2. "after the popup
    LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
    WHERE VNAM = 'ZPDATE'.
    CLEAR L_S_RANGE.
    L_S_RANGE-LOW = LOC_VAR_RANGE-LOW(6). "low value, e.g.YYYYMM (200606) part of key date (20060625)
    L_S_RANGE-LOW+6(2) = '01'. u201C low value e..g. YYYYMM01 (20060601)
    L_S_RANGE-HIGH = LOC_VAR_RANGE-LOW. "high value = input
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'BT'.
    APPEND L_S_RANGE TO E_T_RANGE.
    EXIT.
    ENDLOOP.
    ENDIF.
    Assign if helps.....
    Regards,
    Suman

  • 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,

  • Function module which convert number to days to date

    Hi,
    Any one knows any function module which convert total number of days into date.
    thnaks,
    shilpa k

    Hi,
        FIMA_DAYS_AND_MONTHS_AND_YEARS
    FI_PSO_DAYS_MONTHS_YEARS_GET
    RSSM_CONVERT_DAYSEC2TIMESTAMP
    RSSM_CONVERT_TIMESTAMP2DAYSEC
    Function Modules related to Date and Time Calculations
    DATE_COMPUTE_DAY : Returns weekday for a date
    DATE_GET_WEEK : Returns week for 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.
    MONTH_NAMES_GET : Get the names of the month
    WEEK_GET_FIRST_DAY : Get the first day of the week
    HRGPBS_HESA_DATE_FORMAT : Format the date in dd/mm/yyyy format
    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
    Regards

  • Finding Day from Date i.e. Monday, Tuesday etc

    Hi,
    I need to find out the day from Date. i.e. Monday, Tuesday etc. This is because if the date falls on Saturday or Sunday need to charge difference rates and on weekdays having normal rates.
    Thanks,
    Amol

    We should probably add a function for this as I've certainly seen the requirement before.
    Fortunately it's pretty easy to calculate using a simple rule - the trick is to pick a date in the past that was a Monday, and then use the modulo operator.
    For example:
    The day of the week = (the given date - 1980-01-07) modulo 7
    ie the 7th of January 1980 was a Monday, so every 7th day after that is also a Monday - so combined with the modulo operator this will give you:
    0 monday
    1 tuesday
    5 saturday
    6 sunday
    The only downside is that dates before 1980-01-07 will give a negative modulo (this is distinct from the mathematical modulo operator, but is necessary to be symmetric with the integer division operator truncating towards zero) - so dates before the baseline date will give:
    0 monday
    -6 tuesday
    -2 saturday
    -1 sunday
    You can either choose to write the rules to take this into account, or choose a baseline date so far in the past that it's unnecessary.
    Regards
    Andrew

  • Number of Days from a given Date

    How can one calculate the number of days in a month from a given date?
    Ex: If I pass 07/12/2008 it should return 31

    But your example doesn't meet the OP request. The OP wanted the number of days in a month where the month is determined by a specified date (paraprhased).
    DimaCit gave two credible solutions that met that requirement. Yours just counts the number of days between two apparently arbitrary dates.

  • Can I create a field that calculates number of days from a date field?

    Hi all,
    I need a field that will calculate the number of days elapsed whatever date is entered into the date field, and update that number of days based on the calendar/computer calendar date.  Does that make sense?
    https://www.dropbox.com/s/arkmnsxjkl4r156/AFBS_FacilitySpecialCareList02.pdf
    I set up the form so that my boss can add or subtract clients from the list.  Each client needs to have its own "Days since added to the list" number. Sorta like a little aging report.
    Is this possible?
    Many thanks,
    Laura

    Wow, I'm so stumped.  I tried to copy a bit of formcalc into the exit event for my current date field to try to make this happen, but I can't get it to work.
    My  attempt at scripting is embarrassing, but here it is:
    form1.sf1.CCSub.CCGroup.#subform[0].DateField2::exit - (FormCalc, client)
    form1.sf1.CCSub.CCGroup.#subform[0].NumericField2.rawValue = Date2Num(DateField1, "MM-DD-YY") - Date2Num(DateField2, "MM-DD-YY")
    and here's the file:
    https://www.dropbox.com/s/arkmnsxjkl4r156/AFBS_FacilitySpecialCareList02.pdf
    Can anyone help me get this right?
    Sign me: One Lost Designer
    Thanks!

  • How can I subract a number of days from the sysdate() ?

    I need to display a date that is a certain number of days older than the current date.
    I tried <?xdoxslt:sysdate('yyyy-MM-dd') - 7?> but I get an error.
    Any suggestions would be appreciated.

    I coded this:
    test date : <?xdoxslt:ora_format_date_offset(xdoxslt:sysdate(),7, '-')?>
    I got this:
    test date : 110908 -- today's date, no offset.
    What did I do wrong?
    I got it to work using <?xdoxslt:sysdate() - 7?> (I removed the formatting from the sysdate), but the date format is 110901, not the most common for displaying purposes.
    Any useful hints on how to format the resulting date?

  • Number of Days in Date and 7pm anomaly

    I have found a bizarre behavior with find the number of days for a date( since Jan. 1, 1970 ). I needed a way to calculate the number of days between two dates. I did this by using the getTime() method on the dates, then dividing them by one day in milliseconds (86400000). I then cast them to an int to trucate the decimals. This gave the number of days since Jan 1, 1970. I then subtracted the two 'number of days' values to get the number of days between the 2 dates.
    This was working fine until we ran into a problem of it returning one day to many in a seemingly random pattern. The problem ended up being that after 7pm dividing a date in milliseconds form by a day in milliseconds would return one more day, than if the date was before 7pm.
    example:
    November 1, 2004 00:00:00 = 1099288800000ms = 12723.25 days = 12723 truncated
    November 1, 2004 19:00:00 = 1099357200000ms = 12724.04 days = 12724 truncated
    Why is this? Why is 12am Nov 1 not an even number of days? Supposedly the Date class starts from Jan 1, 1970 00:00:00. If everyday is 86400000ms then this behavior shouldn't happen. Does anyone know why this anomaly happens?

    You need to take into account time zone. If you are at GMT+0 there is no problem (unless you switch to daylight sayings :)
    For example you can take a System.currentTimeMillis() and send it anywhere in the world and it would display locally with the right time.
    I guess you are at -5 hours from GMT. (Eastern time of the US/Canada timezone). The Date object makes corrections for timezone.
    So in England, the time would have been 0 at Jan 1 1970, 00:00:00
    Another thing you may need to worry about is daylight savings changes, which again are handled by the Date object.
    The simplest thing to do is use the Date object. If this is a performance issue you can do some tricks to reduce the impact. e.g. store the default Timezone and Local locale as constants and use these to build the Date object.

  • Subtract business days from date - calculated column

    Hello,
    I had a calculated column on a library that took two dates and found the difference between them in business days, but I am not sure how to subtract business days from a date...for instance I get a start date from a form and I need to
    subtract 10 business days from that date.
    Can anyone help?

    I've always resorted to Javascript/JQuery for that kind of function. I found an old fashioned loop worked the best for me - it supports going forward or backwards. I key it off of a change in a starting date, or sometimes a status change. My actual production
    code takes into account another list where we remove holidays and non-work days.
    newDate = getNextDate(newDate, -3);
    $("input[title='Date Due']").val((newDate.getMonth() + 1) + "/" + newDate.getDate() + "/" + newDate.getFullYear());
    function getNextDate(currentDate, offset) {
    // offset is business days
    var wkend = 0;
    var index = Math.abs(offset); // need positive number for looping
    var neg = true;
    if(offset >= 0) { neg = false; }
    var curDOW = currentDate.getDay();
    var nextDate = new Date(currentDate);
    for(var i=1; i <= index; i++) {
    nextDate.setDate(nextDate.getDate() + (neg ? -1: 1));
    var nextDOW = nextDate.getDay();
    if(nextDOW == 0) {nextDate.setDate(nextDate.getDate() + (neg ? -2: 1));} // Sunday
    if(nextDOW == 6) {nextDate.setDate(nextDate.getDate() + (neg ? -1: 2)); } // Sat
    // alert("offset is " + offset + "start: " + currentDate + ", next date is " + nextDate);
    return nextDate;
    Robin

  • Is it possible to add number of days to date?

    I am working on a form where I need to add number of days to a date and come up with a date.
    Header 1
    Header 2
    example date:  March 1, 2013
    + 30
    = march 31 2013                
    1. is this possible? Header1/cell 1 is a date field. Header 2/cell 1 is a dropdown field (30, 60, 90,120, custom),.
    Header2 cell2 not sure what field to use date or text?
    thank you

    Never mind I figured it out. Thanks

  • Adding an "x" number of Days to Date Object

    Hi guys,
    What I would like to is lets say you have a date object, looking for method/way of adding or subtracting X amount of days from that object.
    This is because I have a list of dates that I would like to follow up on eachother like :
    1/7/06-5/7/06(Date EndDate)
    (Date EndDate + 1) i.e 2/7/06 - 31/7/06
    Thanks in advance

    For anyone that has the same problem this is how I got it working.
    Thanks for the help in the post.
         static Date addDaysToDate(Date startMonth, int days)
              Calendar c = Calendar.getInstance();
              c.setTime(startMonth);
              c.add(Calendar.DATE, days);
              startMonth = c.getTime();
              return startMonth;
         }

  • Adding Number of days to date in XI

    Hi
    I have a scenario where in i have add the number days to date.
    ex: if the date is 02092009 and if the days is 30. then the result of adding days to the date should be 02102009.
    Do we have any readily available UDFs in XI if not it would be appreciated if i can get some procedure to implement this.

    Hi ,
    you can use this code in user defined function
    Calendar cal = Calendar.getInstance();
    /* here u can parse the individual values for year month and day, other calendar function are also available .*/
    cal.set(1999,11,28); 
    /* here instead of value 30 u can pass the specific node integer value to add the no of days.*/
    cal.add(Calendar.DATE, 30);
    return cal.getTime().toString();
    Regards,
    Syed

  • Extrating day from date

    Hi All,
    Extracting day form sysdate is <?xdoxslt:sysdate(‘Day’)?>
    but i want to extract day from <?xdoxslt:ora_format_date_offset(xdoxslt:sysdate('YYYY-MM-DD'),1,'-')?> (sysdate-1 date's day)
    How can i ? any ideas pleae share me.
    Thanks

    DD is working fine
    <?xdoxslt:xdo_format_date($_XDOXSLTCTX,(xdoxslt:ora_format_date_offset(xdoxslt:sysdate('YYYY-MM-DD'),1,'-')),’DD’)?>
    Day and Dy is not working giving result like check boxes
    <?xdoxslt:xdo_format_date($_XDOXSLTCTX,(xdoxslt:ora_format_date_offset(xdoxslt:sysdate('YYYY-MM-DD'),1,'-')),’Day’)?>
    do i need to give any supporting format for xdo_format_date?

Maybe you are looking for

  • ITunes 10.5 Error- Windows Installer Package

    Previously, I had iTunes on my computer, but then got rid of it because my iPod got stolen. I now have a new one, but iTunes 10.5 will not install on my computer. When I've tried to install it, right before it was done installing, an error message po

  • How do I sync with a different username in Palm desktop

    I inherited my husband's Treo 680 when he got his HTC EVO.  I want to keep all the applications/programs he has, but use my own calendar.  I installed palm desktop and created a new username.  How can I sync with that instead of the informtion my hus

  • Importation crashes Iphoto 6.0.6 .How to quit ?

    I have been using Ilife 6.0 for 3 years with OsX 10.3.9. At present around 6000 pictures (1600*1200pel). I tried using the IPhoto library from an other disk booted with OsX 10.5.3, without importing pictures on the 10.5.3 disk. On importation of pict

  • System Recovery hangs on "Windows could not complete the installation"

    Just purchased the recovery media from HP (3 DVD + App/Driver DVD, see below), followed instructions on clean recovery and the install hangs at first Windows login with the following error: "Windows could not complete the installation. To install Win

  • Recording in Application Instance folders

    I have an application running in FMIS 3.5. Everything is working. Now I want to create two application instances, one for a live stream and one for a development stream. That way I can test my application against the development stream without interf