Simple date calculation: add days to a date

Hi,
I'm looking for a function module in APO that can simply add a number of days to a date.
I know I can code (date + days) but would rather a module if possible.
Thks,
William

I know FM /SAPAPO/MSDP_SNPHEU_DAYS_ADD is used in SNP ... but not sure it is suitable for you.

Similar Messages

  • Adobe LiveCycle Designer 8 - Add days to Current Date in another text field

    Hi-
    I am working on an expense report. I have six fields, CurrentDate, and countDate1 through countDate5. The CurrentDate is a Time/Date field which the user can select whatever date is needed with the drop down calendar. The other five countDate fields are "text" fields which will represent Monday through Friday. I would like to add zero days to whatever the user selects as the CurrentDate and make that appear in countDate1 which represents Monday(the CurrentDate the user selects will always be a Monday), add one day to whatever the user selects as the CurrentDate and make that appear in countDate2 which represents Tuesday...and so on. I realize this is probably basic for someone familiar with FormCalc but I'm very new at this.
    This got me very close but I want the user to select the date and not have the CurrentDate already filled in.
    CurrentDate - DateTime field, FormCalc calculation script:
    num2date(Date())
    Date1 - Text field, FormCalc calculation script:
    Num2Date( Date2Num(CurrentDate.formattedValue))
    Date2 - Text field, FormCalc calculation script:
    Num2Date( Date2Num(CurrentDate.formattedValue) + 1 )
    Thanks!
    Brian

    Here is an exmaple of adding days the script is used in the "exit" event for the date select field that has display format of "MM/DD/YYYY". Adding days requires add x number of days to the days since the epoch date for the current date, adding months or years one needs to manipulate the string parts of the date.
    ----- form1.#subform[0].InputDateField::exit: - (FormCalc, client) ---------------------------------
    // fomatted string for selected date
    var sFmtDateValue = $.formattedValue
    var sMsg = Concat("Entered date formatted: ", sFmtDateValue) // build message string
    sMsg = Concat(sMsg, "\u000a" ) // add new line to message
    // convert date string to days since epoch date - format is important
    var fDaysPast = Date2Num(sFmtDateValue, "MM/DD/YYYY")
    // add 7 days to days past epoch date
    var f7DaysPlus = fDaysPast + 7 // add 7 days
    var s7DaysPlus = Num2Date(f7DaysPlus, "MMM DD, YYYY") // format string for 7 days plus
    sMsg = Concat(sMsg, "\u000a", "Plus 7 Days: ", s7DaysPlus) // build message string
    // add 14 days to days past epoch date
    var f14DaysPlus = fDaysPast + 14 // add 7 days
    var s14DaysPlus = Num2Date(f14DaysPlus, "MMMM DD, YYYY") // format string for 7 days plus
    sMsg = Concat(sMsg, "\u000a", "Plus 14 Days: ", s14DaysPlus) // build message string
    // display results
    // work on months
    // get parts of date past epoch date
    var sFullYear = Num2Date(fDaysPast, "YYYY") // get 4 digit year form days past epoch date
    var sMonth = Num2Date(fDaysPast, "MM") // get month form days past epoch date as number
    var sDate = Num2Date(fDaysPast, "DD") // get date form days past epoch date as a number
    var s2Month = Sum(sMonth, 2) // add 2 months
    var s2FullYear = sFullYear
    // if more than 12 months in new date adjust year on number of months
    if (s2Month > "12") then
    s2FullYear = Sum(s2FullYear, + 1) // increment year
    s2Month = Sum(s2Month, - 12) // adjsut months
    endif
    var s2MonthsAdded = Concat(s2Month, "/", sDate, "/", s2FullYear) // date string
    sMsg = Concat(sMsg, "\u000a", "Added 2 months: ", s2MonthsAdded) // display stringxfa.host.messageBox(sMsg, "Sample Adding Days" ,3, 0);
    var s5Month = Sum(sMonth, 5) // add 5 months
    var s5FullYear = sFullYear
    // if more than 12 months in new date adjust year on number of months
    if (s5Month > "12") then
    s5FullYear = Sum(s5FullYear, + 1) // increment year
    s5Month = Sum(s5Month, - 12) // adjsut months
    endif
    var s5MonthsAdded = Concat(s5Month, "/", sDate, "/", s5FullYear) //build Date string
    sMsg = Concat(sMsg, "\u000a", "Added 5 months: ", s5MonthsAdded) // display stringxfa.host.messageBox(sMsg, "Sample Adding Days" ,3, 0);
    // display results
    xfa.host.messageBox(sMsg, "Sample Adding Days and Months" ,3, 0);

  • How i can add days to a date using sql

    Hi.
    Sorry the question, it's a very simple question, but i'm not finding the answer to that.
    I need some function that act just like the function add_months, but instead adding months, it need to add days to a date.
    I've used the function add_days once, but now, my select returns an error code when i try to use that function.
    My Oracle version is Oracle8 8.0.5.0.0
    runnig under Linux.
    Thanks,
    Klaus Paul

    To add days just do date arthmetic. Ex
    SQL> select sysdate+10 from dual;
    SYSDATE+1
    05-MAR-00
    add_days is a not Oracle date function.
    null

  • Require a function module to add days to a date?

    My purpose is to add days to a particular date and get the resulting date. I tried using this function module "RP_CALC_DATE_IN_INTERVAL", but the problem is this function module only accepts two digits for days. i.e. i am only able to add a maximum of 99 days to a particular date, but i do want to go further and add more so please tell me if there is any function module which shall help me add 3 digit days to a date.

    Hi Kiran,
    You can directly add days to the date.
    Eg:
    DATA date LIKE sy-datum.
    DATA days TYPE i.
    date = sy-datum.
    days = 100.
    date = date + days.
    WRITE date.
    Regards
    Wenceslaus

  • How can I add days to a date?

    I need to find a way to add days to a date. For example, today is 10/3/03 and I want to add 180 days to that. How do I do that? Here is my code so far....
    import java.util.*;
    import java.text.*;
    public class Loan
         String date;
         String loanEndDate;
         public void setDate()
    GregorianCalendar gregNow = new GregorianCalendar();
    Date now = gregNow.getTime();
    DateFormat shortDate = DateFormat.getDateInstance(DateFormat.SHORT);
    date = shortDate.format(now);
    public String getDate()
    return date;
    public void printLoanBegDate()
              System.out.println("Loan Beg Date: " + date);
         public String setLoanEndDate()
              loanEndDate = (getDate() + 180);
              return loanEndDate;
         public void printLoanEndDate()
              System.out.println("Loan End Date: " + loanEndDate);
    The output is displayed by the following program:
    public class DemoLoan
         public static void main(String[] args) throws Exception
         Loan anLoan = new Loan();
         anLoan.setDate();
         anLoan.printLoanBegDate();
         anLoan.setLoanEndDate();
         anLoan.printLoanEndDate();
    The output is as follows:
    10/4/03
    10/4/03180 - - Why does this print the 180 afterwards? How can I get that to display the date 180 days into the future??
    Thanks

    Re: storing your dates as Dates, I mean don't have a field in your class called "date" which is a String. Have a field in your class called "date" which is a Date. If one aspect of your class is a moment in time, then use the java class that best represents a moment in time: java.util.Date. Don't make things more complicated than they have to be.
    Re: adding, it's in the docs:
    http://java.sun.com/j2se/1.4.1/docs/api/java/util/Calendar.html
    and
    http://java.sun.com/j2se/1.4.1/docs/api/java/util/GregorianCalendar.html
    But anyway it's like:
    Calendar c = new GregorianCalendar(); // now
    c.add(Calendar.DATE, 180); // 180 days from now
    Date nowPlus180 = c.getTime();
    DateFormat shortDate = DateFormat.getDateInstance(DateFormat.SHORT);
    System.out.println(shortDate.format(nowPlus180));

  • Add days to a date - BI Publisher

    Hello,
    I am trying to add 7 days to a date. The date starts as DD-MM-YY format, but I need it to display as DD.MM.YYYY.
    I can get the following to return the date in the correct format:
    <?xdofx: to_date(to_char('20'||substr(DUN_DATE,7,2)||'-'||substr(DUN_DATE,4,2)||'-'||substr(DUN_DATE,1,2)),'DD.MM.YYYY')?>
    But I am unable to add 7 days to this date. I have tried using +7 in various places in the tag but no luck. Here are some things I've tried:
    Within the "to_char" function causes error "oracle.xdo.parser.v2.XPathException: Cannot convert 2010-11-30 to number"
    <?xdofx: to_date(to_char('20'||substr(DUN_DATE,7,2)||'-'||substr(DUN_DATE,4,2)||'-'||substr(DUN_DATE,1,2)+7),'DD.MM.YYYY')?>
    Within the "to_date" function causes the same error "oracle.xdo.parser.v2.XPathException: Cannot convert 2010-11-30 to number."
    <?xdofx: to_date(to_char('20'||substr(DUN_DATE,7,2)||'-'||substr(DUN_DATE,4,2)||'-'||substr(DUN_DATE,1,2))+7,'DD.MM.YYYY')?>
    Outside all functions itstill errors, but with a slightly different error: "Cannot convert 30.11.2010 to number"
    <?xdofx: to_date(to_char('20'||substr(DUN_DATE,7,2)||'-'||substr(DUN_DATE,4,2)||'-'||substr(DUN_DATE,1,2)),'DD.MM.YYYY')+7?>
    Any ideas how to get the calculation to work correctly?
    Thanks in advance,
    JJ

    Found a soution, it's not very clean and there are probably better ways, but it works.. if anyone has alternatives I'd be intereseted.
    1.) Set a variable XDUN that converts the date from DD-MM-YY to the the BI-supported date format YYYY-MM-DD using substring and concat functions:
    <?xdoxslt:set_variable($_XDOCTX, ’XDUN’, concat('20',substring(/ARDLP/LIST_G_CORRESPONDENCES/G_CORRESPONDENCES/DUN_DATE,7,2),'-',substring(/ARDLP/LIST_G_CORRESPONDENCES/G_CORRESPONDENCES/DUN_DATE,4,2),'-',substring(/ARDLP/LIST_G_CORRESPONDENCES/G_CORRESPONDENCES/DUN_DATE,1,2)))?>
    2.) Set another variable XDUN7 based on the first variable, and add 7 days there. Also formats the date in DD.MM.YYYY format:
    <?xdoxslt:set_variable($_XDOCTX, ’XDUN7’,xdoxslt:ora_format_date(xdoxslt:ora_format_date_offset(xdoxslt:ora_format_date(xdoxslt:get_variable($_XDOCTX,’XDUN'), 'YYYY-MM-DD'),7,'+'),'DD.MM.YYYY'))?>
    3.) Call the variable to display the date + 7
    <?xdoxslt:get_variable($_XDOCTX, ’XDUN7')?>
    Thanks,
    JJ

  • Jquery how to add days to a date and display in a sharepoint field

    hi
    I have a column 'Date' , where user will select the date . Another column Grace Period where user enters number. I have a column 'Due Date' = Date + Grace Period
    I cannot use out of the box calculated column as it is not displayed in the newform.aspx.
    Is there any way to achieve it
    Thanks

    To get & set value via jquery, you first need to download jquery and save query in your site. Later add jquery ref to your script then get the column value. Refer below thread:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/a9fb3163-109c-4309-96d2-4f2f19e6824a/sharepoint-and-jquerygetting-setting-sharepoint-form-fields?forum=sharepointgeneralprevious
    http://stackoverflow.com/questions/8559559/javascript-to-get-sharepoint-form-field-value-to-a-variable
    Since you are new so i would suggest you that first try with simple query on page then build the advance.
    http://sympmarc.com/2011/05/03/adding-jquery-to-a-sharepoint-page-step-one-always/
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Add Days to a Date field

    Hi all,
    I have the following requirement:
    I have a date field 0calday and the user would like to add a specific no.of days to it, like for example 10 or 15 days. Then we use this computed date field in calculations in the query. Could you please help and let me know how we can no.of days to a date field? And also how we can compute no.of days between two date fields?
    Regards,
    Ashmith Roy

    Hi Ashmith,
        When the user enters both date and no. of days, and if you want to calculate no of days from the user entered date I think you can go for an exit where you can use the available function module which calculates the no of days from starting of the month for the given date. Then you can add up the days entered by the user and use another available function module which converts it to the dat format again based on the given days and the old date. I don't remember the function module names but i am sur ethey are available.
    If the above thing is made possible then I think getting no of days between two dates is not a problem. Well i hope this will help you.

  • Calculating Business Days in a Date Range

    I have two questions:
    1. Does anyone know a better formula for calculating business days in totals?
    I am currently using the formula in https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/701a52c3-6b1e-2b10-21b3-a6e101be1a0f
    I tailored to my needs.  However, there are still a lot of manual maintenance every year. 
    2. I have many reports that need the formula.  It is very consuming to update the formula in each report.  Does anyone know a better way to do it? 
    I use Crystal XI. 11.0.0.895.  We do have a Crystal Enterprise server hosted in another department.

    Not sure if this is any simpler but you could save this as a custom function, that way you will have to modify it once a year for the holidays.
    numbervar days;
    datevar date1 := minimum({?My Parameter});
    datevar date2 := maximum({?My Parameter});
    days := DateDiff ("d", date1, date2) -
    DateDiff ("ww", date1, date2, crSaturday) -
    DateDiff ("ww", date1, date2, crSunday);    // this will give you the number of business days
                                                        // (excluding Saturdays and Sundays) for a given date range.
    // then, for each holiday, you can enter lines like this
    if date(2008,01,01) in {?My Parameter} then days := days - 1;
    // The final tally of DAYS should give you the total business days in a date range.
    totext(days,0);
    where {?My Parameter} is the date range.

  • How To Add Days into a Date from java.util.Date class

    I have a problem when i wants to add 2 or days into a
    date object geting by java.util.Date class. so please help me resolve this issue?
    for e.g i have a date object having 30/06/2001,
    by adding 2 days i want 02/07/2001 date object ?
    Code
    public class test2
    public static void main(String args[])
    java.util.Date postDate = new java.util.Date();
    myNewDate = postDate /* ?*/;
    Here i want to add 2 date into postDate

    Use Calendar...
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(Calendar.DAY, 2); // I'm not sure about that "DAY"

  • How do I add days to a date in Numbers?

    I want to build a chart that will add 151 days to a date. In Numbers 08 I used (date entered + 151) and it worked. How is it done with Numbers 09? I get an error that I can not compare dates and numbers

    e3farms,
    As far as I can see, with respect to your problem Numbers '09 works the same way as its predecessor. In the example below 100 is added to Jan 20, 2009, yielding the same result in each case.
    pw

  • Add days to a date field on adobe form

    Hi,
    I have to add 15 days to a date field how i do that on javascript or formcalc?
    Thank you in advance.
    Miguel

    Hi,
    The below is in js code.
    I had a caluclated date time field on the screen which displayed the current date.
    The below code will just add 15 days to the day part of the date.
    for moving it to month if its more than 31 is to be handled by you.
      var valArray = this.rawValue.split("/");
      var newDate = valArray[1] + 15;
      var actualVal = Date.parse(newDate+"/"+valArray[0]+"/"+valArray[2]);  
    var dateType=new Date(actualVal);
    this.rawValue = dateType;
    Hope this helps you out, let me know if you need any more info.
    Cheers,
    Sai

  • Add days to a date

    Hi all,
    I want to add some days to a date and get the final date.
    Example : I have a date in a field GS_DATE as 06/15/2006. Now I want to add some days say 14 days to GS_DATE and get the final date as 06/29/2006. How can I get this.
    Waiting for replies. Thanks

    hi Raju,
    This thread has a solution to the same requirement as of yours
    Check this thread out
    Re: Function module for DATE
    call function <b>'RP_CALC_DATE_IN_INTERVAL'</b>
             exporting
                  date      = '06/15/2006'
                  days      = 14
                  months    = 0
                  signum    = '+'
                  years     = 0
             importing
                  calc_date = wa_date.
    Regards,
    Santosh

  • Add days to the dates when user enter +

    hello ,
    i have requirement that when user enter + 30 in date field he got + 30 dayas of current date is thr any why to do this it is modulpool and i have taken date field on screen.

    here is sample code to show next and previous month on button click and show current month
    and year default.
    REPORT  ztn_datechk_button.
    TABLES sscrfields.
    TYPE-POOLS icon.
    DATA month TYPE i.
    PARAMETERS: date TYPE spmon .
    INITIALIZATION.
      date = sy-datum+0(6) .
      "date = sy-datum+0(2) - 1.
      IF date+4(2) < 1 ."or date+4(2) > 12.
        date+4(2) = 12.
        date+0(4) = date+0(4) - 1.
      ELSEIF date+4(2) > 12 ."or date+4(2) > 12.
        date+4(2) = 1.
        date+0(4) = date+0(4) + 1.
      ENDIF.
      SELECTION-SCREEN  PUSHBUTTON 50(15)  but1 USER-COMMAND prev VISIBLE LENGTH 3.
      SELECTION-SCREEN   PUSHBUTTON 53(15) but2 USER-COMMAND next VISIBLE LENGTH 3.
      CALL FUNCTION 'ICON_CREATE'
        EXPORTING
          name   = icon_previous_value
          info   = 'PREVIOUS'      "text = 'Button 2'
        IMPORTING
          RESULT = but1
        EXCEPTIONS
          OTHERS = 0.
      CALL FUNCTION 'ICON_CREATE'
        EXPORTING
          name       = icon_next_value
          info       = ''      "text = 'Button 2'
          add_stdinf = ''
        IMPORTING
          RESULT     = but2
        EXCEPTIONS
          OTHERS     = 0.
    AT SELECTION-SCREEN.
      CASE sy-ucomm.
        WHEN 'PREV'.
          date = date+0(6) - 1.
          IF date+4(2) < 1 ."or date+4(2) > 12.
            date+4(2) = 12.
            date+0(4) = date+0(4) - 1.
          ENDIF.
        WHEN 'NEXT'.
          date = date+0(6) + 1.
          IF date+4(2) > 12 ."or date+4(2) > 12.
            date+4(2) = 1.
            date+0(4) = date+0(4) + 1.
          ENDIF.
      ENDCASE.
      IF date+4(2) < 1 OR date+4(2) > 12.
        MESSAGE 'Invalid Month' TYPE 'E'.
      ENDIF.

  • How to add days to a date?

    Dear all
    I work with jdeveloper 11.1.4
    I have created my BC.
    I have 3 attribute on Vacation entity.
    startDate
    numberOfDays
    endDate
    I want to set the endDate value to be startDate+numberOfaDays
    Can any one helps me.

    You can achieve the same by writing a small piece of code in EntityImpl class or backing bean,depends on the use case.
    if (VO.getCurrentRow().getAttribute("startDate") != null){
    Calendar cal = Calendar.getInstance();
    cal.setTime(convertDomainDateToUtilDate((oracle.jbo.domain.Date)VO.getCurrentRow().getAttribute("startDate")));
    cal.add( Calendar.DATE, numberOfDays);
    oracle.jbo.domain.Date domDate = convertUtilDateToDomainDate(cal.getTime());
    VO.getCurrentRow().setAttribute("endDate",domDate );
    In the above code the utility method "convertDomainDateToUtilDate" just converts the jbo.domain.Date to java.util.Date and "convertUtilDateToDomainDate" method does the reverse.
    The code above holds good for backing bean but if You need to implement the same in EntityImpl then you just have to tinker around the code to get the proper entity attribute and set them properly.
    Hope this helps.
    -Sanjeeb

Maybe you are looking for

  • Is anybody use LR with Photoshop Elements 6 for Mac ?

    I've just bought Photoshop Elements 6 for Mac on a PM G5 (OS 10.5.2). PSE works but LR don't find it as external editor. I have done what is the Knowledge Base, I've deleted all adobe products (and all related files in /Library an home/Library) and r

  • How to use Alias name in OData service in SAP HANA

    Hi,      I need to change one column name with alias of another name in odata service definition or odata url running in rest client. I am trying to give alias name with as key in the service definition like sql query. ex: There is one table with col

  • [CLOSED]How to create a custom messages

    Hi All, I have a page and one save button .on press of save button, i want to show a custom message like "Applied changes are saved." Can anybody please elaborate how to create a custom message and how to show it through Controller. may i use OAExcep

  • RMAN and Begin backup mode

    Hi guys I have a couple of questiopns... I want to know whether data is written to datafiles by DBWR when the datafile is in begin backup mode. What is the difference in archive log creation during normal operation of a database and operation of a da

  • Blank popup when try to add an exchange subscriber with Unity 8.03 Exch 2003sp2

    Hi, I meet an issue when trying to add manually a new exchange subscriber using Unity 8.03 + external Exch 2003sp2: After, filling up name, firstname... when I click on Add button, a blank popup appairs (whitout errors) and nothing happens (the subsc