Add 30 days to Date?

How do I add 30 days to Date date?
java.util.Date date = new java.util.Date();
DateFormat d = DateFormat.getDateInstance(DateFormat.SHORT);
System.out.println(d.format(date));

Maybe something like this:
long ONE_DAY = 1000 * 60 * 60 * 24;
Date d = new Date();
d.setTime( d.getTime() + 30 * ONE_DAY );
Problems can arise if your locale uses daylight
savings time. No kidding. Use GregorianCalendar as other posters have suggested.
Use the setTime() method to set the date within the calendar instance. Invoke add(GregorianCalendar.DATE, 30) to add 30 days to the calendar, and then call getTime() to get the new Date back.
Also, ask yourself if you really want to add 30 DAYs or 1 MONTH. If you really want the latter, do that explicitly by calling add(GregorianCalendar.MONTH, 1).

Similar Messages

  • Add-days-to-date  throwing error in formcalc

       I am receiving an error of Error: Accessor 'add' is unknow.
    Any help is much appreciated.
    Justin    

    form1.page2.invoiceTable.row1.boosterDate1.rawValue = add-days-to-date(form1.page2.page2Date,4)
    The form1.page2.page2Date is copying a cell that has:
    $.rawValue = num2date(Date(), "MM/DD/YYYY")
    I'm not sure where I'm going wrong here.  I've also tried using javascript and can't get that to work either.  I am trying to take a date and add days to it dynamically.  So user selects "weeks" from a dropdown and "years" from a dropdown and from that point I want to add that amount of days to today's date.  I can get the math to work but for the life of me I can't figure out how to make the Date() function work to add some days to it.
    Justin

  • Add Days To Date

    Hi Everyone,
    I have been reading about adding an onchange event to a field in a form. My dilemma is below;
    I have a form where there is a date field that shows the end date of something. I want to auto populate another field with that same end date plus a number of days. I can already using onchange=$x('P7_DEADLINE').value=P7_ENDDATE.value to populate the deadline field with the exact date entered in the enddate field, but I need to add thirty days to the ENDDATE to create the DEADLINE date.
    Any slick and easy ideas?
    Thanks from a newbie...
    Derek

    Hi,
    Add javascript to page HTML header
    <script type="text/javascript">
    function setDeadline(pStart,pAddDays,pSetItem){
      var d = new Date(pStart);
      d.setDate(d.getDate()+pAddDays);
      $x_Value(pSetItem, (d.getMonth()+1)+"/"+d.getDate()+"/"+d.getFullYear());
    </script>And then item P7_ENDDATE HTML Form Element Attributes
    onchange="setDeadline(this.value,30,'P7_DEADLINE')"In this example date format need to be mm/dd/yyyy
    Br,Jari

  • UDF: add day to date

    Hi all,
    I'm currently working with IDoc INVOIC02, and while obtaining a date value (E1EDK03-DATUM) i have to sum one day, because for some reason they don't want that the idoc date creation is the same as other date that i map
    The only problem is not i'm not really familiar with Java functions
    - Could you help me by providing an UDF function that obtains a date (idoc format, YYYYMMDD) add 1 day to that date?
    Thanks!!

    Hi sudhir, many thanks for and your response!! (and the mail too!)
    but the problem with graphical mapping is that the map is too big! my map is more than less as your capture, but with context changes so i have to ask many times the same
    let me explain:
    1º if qualf = 002 (obtain date) and if qualf = 012 (obtain the corresponding date) are equal then map qualf012 - date+1 (i have the udf to do that in this post), if not map the date with qualf012
    2º but sometimes qualf = 002 could not come, so i have to check that first (if qualf = 012 is empty i dont need to check because the map is 1.1 so it would fail anyway)
    3º aditionally, after the big IF to check if they're equal, i have to map for if/else the qualf corresponding, but i have to check context AGAIN! because if not i'm getting the wrong qualf (the first one found)
    so i was wondering if i could just do a udf that compares the two dates, and after that sum accordingly!
    here's your example: http://img395.imageshack.us/my.php?image=getattachmentom5.jpg
    here's my map: http://img60.imageshack.us/my.php?image=mymaplz6.jpg
    if i don't do context change all the times i lost the real value!
    the problem is really solved already but i did wanted to simplify that, anyway if that's not possible i maybe left it like it's done now..

  • Need to add days to date on a "batch report in documents structure" report

    I am trying to create an expiration date based on  UDF "shelflife" formatted as number for the number of days a product has before it expries ie. 120 days. I have a UDF "expdate" formated as date. I am trying to create a date based on the receive date from purchasing. The basic math would be as follows:
    [receiving date]+[shelflife]=[expdate]. I need [expdate] to show up on the report. All UDF are on the Item master.
    Thanks for the help in advance. I am new to SAP. I am assuming formatted search. Is there a e-learning on this?

    I am believing you are talking about using this query as a Formatted search on the Expiration Field when you creating the Batches either in the Goods Receipt / Production Receipt / AP Invoice (whenever you bring this batched managed Item into inventory)
    The query I have given you is supposed to be link to the Expiration Date field on the Batches window where you enter the Batch number, quantity, etc.  The admission date is one of the columns which should be visible on the screen since my query uses this date for calculating the expiration date.
    The T0.ReOrderQty field in my query should be substituted by the user field you have on the Item Master for shelf life (I believe this is in days)
    Here is the link for formatted search PDF 
    https://websmp105.sap-ag.de/~sapidb/011000358700006374892006E/FMS.pdf
    Let me know
    Suda

  • Help in add days in Date

    i m working with SAP B1 SP01 and i want to put delivery date in Purchase order with the help of formated search which will get date from docdate and add item lead time in this date. i have write a query for this it works well in sql server but gives error in formated search plz do help me
    Select $[OPOR.docdate] + (select leadtime from oitm where itemcode='FL0001')
    Regards
    Rahil Hassan

    Try this:
    Select dateadd(d,(select leadtime from oitm where itemcode='FL0001'),$[OPOR.DocDate])

  • Adding days of date

    Dear all
    Using form6i and run in c\s
    is it possible to add days of date.. example the format of date is 02-mar-07
    in text item i enter 3 then the date will become 05-mar-07. it depends what number will be entered in textitem and it will add to the days of date..
    |Another example is: date format is 29-mar-07.. i entered 4 in textitem the date will become 02-apr-07 ...
    Could anyone help me to do this or is there any ideas must simplest than this that can add a days of a date plz help me need in school requirements...

    Say, you have two items
    b_day.txt_refdate - the refernce date.
    b_day.txt_inc - the number which should b added.
    b_day.txt_result - to store the result.
    in WHEN-VALIDATE-ITEM of b_day.txt_inc, write
    begin
    b_day.txt_result := to_date(b_day.txt_refdate + b_day.txt_inc,'dd-mon-rrrr');
    end;

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

  • 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));

  • How to add a day to Date() ( i.e 2002Oct10 to 2002Oct11 )

    Hi anyone, How to add a day to Date().
    <%
    String R, fulldate;
    java.util.Date Rdate = new java.util.Date();
    R = Rdate.toString();
    String DD=Rdate_string.substring(8,10);
    String MM=Rdate_string.substring(4,7);
    String YY=Rdate_string.substring(24,28);
    fulldate = YY+MM+DD;
    //ie. fulldate = 2002Oct10 but I want it to be 2002Oct11
    %>
    pls. help and thanks a lot.

    Hi,
    Please replace the following line in your program,
    String DD=Rdate_string.substring(8,10));
    with
    String DD=String.valueOf(Integer.parseInt(Rdate_string.substring(8,10)) + 1);
    This will work fine. Basically what this code is doing is that, it will get the Integer from the String, increment it by 1 and then change the integer to the String again.
    Hope this helps,
    Rajat,
    OTN Team

  • How do you add a due date 2 days from today in a workflow

    So I'm creating a workflow that creates a task in a task list after I've added a new item to my clients list. So for example by adding a new client to the client list, a task will be set to 'Complete all contact details'. All I want to do is set a predetermined
    due date, so instead of picking the current date or a specific date I want the workflow to work out the due date 2 days from today. How can I do this? Please note that I want to be able to change the predetermined due date in the same work flow, so for another
    task I'd like it to be 4 days or a week from today.
    Thanks in advance! :)

    Hi Sarah,
    Thanks for posting your issue, 
    Go to your Tasks List and go into the List Settings. Click on the Due Dat column and tick the Calculated radio button. In the formula, put [Today]+2 and click OK. Go back to the list and select New and you'll see the Due Date is 2 days in the future.
    If you need to do this within the workflow, you'd use an Add Time to Date action, setting it up to add 2 days to the Current Item created by field. Then, you'd use an Update item action to update the Due Date field to the date variable the Add Time to Date
    action output.
    Also, browse below mentioned URL for more details.
    http://dlairman.wordpress.com/2010/10/14/limiting-sharepoint-workflow-due-dates-to-business-days/
    http://www.documentmanagementworkflowinfo.com/sample-sharepoint-workflows/4-ways-set-date-value-sharepoint-designer-workflow.htm
    I hope this is helpful to you, mark it as Helpful.
    If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS)
    Blog : http://sharepoint-community.net/profile/DharmendraSingh

  • Keyboard shortcuts: current day and date, and current time?

    I would like to know keyboard shortcuts for entering current day and date, and current time (separated entries) in Numbers. Something that Excel does easily. Thank you, Ian

    Ian,
    Numbers does not have predefined key command for Insert Date & Time as you can see from this screenshot:
    All menus show the key commands on the very right (if there is a ke command).  You can add you own, custom, key commands by opening system preferences and selecting the Keyboard panel, then the "Keyboard Shortcuts" segment:
    Click the "+" then a modal dialog will appear.   Select the application from the pop, then enter the exact name if the menu item, and, finally, your desired key combination:
    You can do this for any application

  • How do I get numbers to automatically add the next date down a column in numbers?

    How do I get numbers to automatically add the next date down a column in numbers?

    Hi Dd,
    If you want the next date automaitcally  filled in when you add a row to the bottom of the table, you can use a formula.
    Here's an example, done in Numbers 2.3 (Numbers '09). The method is basically the same in Numbers 3.
    Formulas in row 3:
    B3: =B2+1
    C3: =C2+7
    D3: =D2+14
    These have been filled down to the last row of the table.
    The same table is shown below after three rows have been added by dragging the Row control handle (below the tab for row 7) down. No changes other than adding thse three rows were made by the user.
    Note that rows 1 and 2 are header rows, and that row 2 contains the starting date for the seraies of date in each column. In the formula, the number at the end tells Numbers how many days to add to the previous date to get the next date.
    Autofill of the formula requires that every non-header cell located above the cell into which the formula is to be filled contains the same formula.
    Regards,
    Barry

  • How to add months in date

    Hi All,
    I have an query.
    query:
    date format                      output
    11/06/2014                11/06/2014 + 2 months= 11/08/2014
    10/05/2014                10/05/2014 + 2 months= 10/07/2014
    i am stuck due to there are 28/29/30/31 days are in months. so i can not proceed for add days.
    Thanks in advance..
    Ranjeet

    Hi Ranjeet,
    Please refer below thread to do in universe-
    Reg; Webi Reporting Queries
    However, If you want to do at report level follow below-
    Create Variables-
    MonthNum=If Mod(MonthNumberOfYear(<Cal Date>)+2 ,12)=0 Then 12 Else  Mod(MonthNumberOfYear(<Cal Date>)+2 ,12)
    TargetMon=MonthNumberOfYear(RelativeDate(<Cal Date> ,(DayNumberOfMonth(LastDayOfMonth(<Cal Date>))+DayNumberOfMonth(LastDayOfMonth(LastDayOfMonth(<Cal Date>)+1)))))
    Intermediate Date1=RelativeDate(<Cal Date> ,(DayNumberOfMonth(LastDayOfMonth(<Cal Date>))+DayNumberOfMonth(LastDayOfMonth(LastDayOfMonth(<Cal Date>)+1))))
    Intermediate Date2=LastDayOfMonth(<Intermediate Date1>-5)
    TargetDate= If <TargetMon>-<MonthNum>=0 Then <Intermediate Date1> Else <Intermediate Date2>
    Use TargetDate variable in your report column.
    Replace <Cal Date> to your date column in above formula. Let us know if it works.
    Thanks,
    Anuj

Maybe you are looking for