Deducting days from a date

How do I deduct a specified no. of days from a datestring.
I need to be able to get the date 30 days from a specific date for example :
6/5/2003 given date
less 30 days
5/6/2003 is the date that i need

import java.util.*;
public class TodayMinus30
     public static void main(String[] args)     
          Calendar clCalendar = Calendar.getInstance();
          clCalendar.add(Calendar.DATE, -30);
          Date myDate = clCalendar.getTime();
          System.out.println(myDate.toString());
}

Similar Messages

  • Extract data on report between last 30 days from current date.

    Hi Experts,
    Ealrier i had provided user promt to select the date range, now i need to schedule the report for this i have to set the date between last 30 days from current date.
    How can i add this in formaula on record selection.
    before:
    {pm_process.pm_creation_date} in {@Start Date to UTC} to {@End Date to UTC}
    I tried:
    {pm_process.pm_creation_date} in CurrentDate() - 30 to CurrentDate()
    But this is diplaying me only data of 30th date from current date.
    Please advice.

    Hi Brian,
    Thank you!
    1. I have not created any function for {pm_process.pm_creation_date} in [CurrentDate() - 30 to CurrentDate()] i am just adding this on Record Selection and its not helping.
    2. {pm_process.pm_creation_date} in Last30Days; this is throwing below error.
    please advice what to be done?

  • Trying to subtract days from a date

    Im trying to subtract days from a date.
    When i use this query:
    select sysdate-:p21_DAYS_OLD from dual;
    it displays the correct date but not in the correct format. It is displaying 12-AUG-09 instead of 08/12/2009.
    I tried this query but i get the ORA-01722: invalid number error.
    select to_char(sysdate,'MM/DD/YYYY')-(:p21_DAYS_OLD) from dual;
    Can someone help me please?
    Deanna

    Dclipse03 wrote:
    Im trying to subtract days from a date.
    When i use this query:
    select sysdate-:p21_DAYS_OLD from dual;Just set the NLS_DATE_FORMAT parameter for your session and execute the above query.
    ALTER SESSION SET NLS_DATE_FORMAT='MM/DD/YYYY'
    /

  • 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

  • Subract n days from a date

    Using 2004s service pack 10.  Is there a way to subtract x number of days from a date using a formula?  I saw an earlier post that said to use function module RP_Calc_Date_In_Interval but when I search for this it says it doesn't exist.  Is it called something else in 2004s?  Is the only way to accomplish this using a function module?

    If formula variable does not work and if the "no of days is a fixed number", then next alternative is to have a routine in transformation and make the subtraction.
    Ravi Thothadri

  • Payment term - 90 days from document date on 15th of the month

    Helllo,
    Can anybody please tell me how to configure following payment term?
    90 days from document date on 15th of the month i.e. as follows:
    u2022     Document date = 03.01 => Due date = 15.04 (90 days completes on 03.04)
    u2022     Document date = 15.01 => Due date = 15.04 (90 days completes on 15.04)
    u2022     Document date = 27.02 => Due date = 15.06 (90 days completes on 28.05)
    u2022     Document date = 18.03 => Due date = 15.07 (90 days completes on 16.06)
    Regards,
    CHetna Pant

    Dear,
    Define no 'fixed day' and 'additional months'. Go to payment terms section and enter 90 in 'No. of days'

  • Subtracting Days from a Date

    Am using Acrobat Pro 9 for Windows.  I have a form where I want to subtract days from Date1 and the result is Date2.  The Date1 and Date 2 text boxes are unformatted.  I've tried reading the "date" articles and experimental with some formulas but I'm afraid I'm still Acrobat illiterate.  Any ideas?  Thanks.

    It would be best if you set up the Date1 field to be formatted as a date. That way, Acrobat uses a built-in routine to automatically validate that the entry represents a valid date. You can then use a custom Calculate script for the Date2 field that looks someting like:
    // Custom Calculate script for text field
    (function () {
        // Get Date1 field value
        var v = getField("Date1").value;
        // If field is empty, blank this field
        if (v === "") {
            event.value = v;
            return;
        // Convert the date string to a date object
        var d = util.scand("mm/dd/yyyy", v);
        // Subtract 5 days
        d.setDate(d.getDate() - 5);
        // Set this field's value
        event.value = util.printd("mm/dd/yyyy", d);
    Change the date format (mm/dd/yyyy) in the code above to match what you want to use.

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

  • Subtract days from given date

    hi,
    Is there any FM which will subtract the no of days from a given date.
    I hv tried with SUBTRACT_TIME_FROM_DATE , but having some config issue. And it is not available in 3.1H version.
    Some one can help me out...
    Thanks,
    shiva

    Hi,
    use the FM RP_CALC_DATE_IN_INTERVAL
    and check the sample output.
    Import parameters               Value             
    DATE                            10/10/2004        
    DAYS                            05                
    MONTHS                          00                
    SIGNUM                          +                 
    YEARS                           00                                                                               
    Export parameters               Value             
    CALC_DATE                       10/15/2004  
    Regards
    vijay

  • Get the date of a particular week day from given date

    I have a given date.
    from that date i want to get the date of sunday of that week
    wat is the best possible way to do the same.
    for eg:
    if i am given 03/11/2007 which is a saturday
    i want to get 27/10/2007 which is the sunday which falls in the same week as of 03/11/2007
    can anybody please help.

    hi,
    Here I am posting code for your requirement.
    Here I am hard coding the date value.
    import java.util.*;
    public class DateTest{
         public static void main(String ar[]){
              Calendar calendar =new GregorianCalendar(2007,7,4);
              System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
              calendar.set(2007,7,4-calendar.get(Calendar.DAY_OF_WEEK)+1);
              System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
              System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
    }

  • Getting Day from the date :

    Hi,
    I want to get the day(Monday ,tuesday.. like that) and the input parameter for that function is the date let say 02/14/2006.

    > Can you explain it more elobarately.Because the
    content i got from that link some what puzzling to me.
    I posted the link to that class at 13:26, you again posted a reply at 13:40. If my calculator is correct, you've spent about 14 minutes looking at that class and the examples from that page. I also wouldn't understand it in that time.
    Try the examples on the page, alter them, see what happens. Come back here with a specific question.
    Good luck.

  • To extract a day from a Date variable

    Hi
    I have a date variable and i want to get the day into a PL/SQL variable.Can you tell me how to do that .
    eg I have 12/30/2002 (MMDDYYY)
    and i want 30 in another variable ..
    Thanks in a advance

    SQL> declare
      2  ln number;
      3  begin
      4  ln := to_char(sysdate, 'DD');
      5  dbms_output.put_line(ln);
      6  end;
      7  /
    22
    PL/SQL procedure successfully completed.
    SQL>
    [pre]
    Piece of cake.  No, thanks, I've just had breakfast.
    APC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Need to subtract one day from the date appearing

    Hi, I am modifying a script in such a way that for an output type there is an invoice date appearing.  This invoice date should be back dated to 1 date less to the actually date that is appearing currently.
    For ex the date is 2007.08.30 it should appear as 2007.08.29.
    While debugging I found that it is picking up the data for the date from the structure vbdkr and the field is fkdat. From the following code in the script.
    /:   DEFINE &SALES_ORDER& := &VBDKR-VBELN_VAUF&
    /:   INVOICE DATE,, : &VBDKR-FKDAT&
    What changes do I need to make the changes in the script or in the driver program?
    Can you please suggest?
    Thanks.

    Hi..
    You can get this Functionality by Calling a FORM (subroutine) from the Script Layout itself  There is no need to change the Print program.
    Eg:
    In the layout set -> window -> text elements. Write this before displaying invoice date
    /: PERFORM F_DATE_SUB IN PROGRAM ZPRG01
    /: CHANGING &VBDKR-FKDAT&
    /: ENDPERFORM
    INVOICE DATE,, : &VBDKR-FKDAT&
    Create the report program ZPRG01: In the program ZPRG01
    FORM F_DATE_SUB TABLES INTAB STRUCTURE ITCSY
                                                  OUTTAB STRUCTURE ITCSY.
    DATA: L_DATE TYPE D.
    READ TABLE OUTTAB INDEX 1.
    L_DATE = OUTTAB-VALUE. "you need to convert here
    SUBTRACT  1 FROM L_DATE.
    OUTTAB-VALUE = L_DATE.
    MODIFY OUTTAB INDEX 1.
    ENDFORM.
    reward if Helpful.

  • How to get Unpaid balance from 30 days from chose date

    hello All,
    i have to get the UPB (unpaid balance) from daily table and i need to check the UPB from last month. there are seperate daily and monthly tables. And depending on user enter date range as parameter value i need to look up the monthly table.
    for example if user enter date range 08/01/2011 to 08/15/2011 then i need to check for month of July from monthly table to get previous month UPB.
    please help
    Thanks

    Have you tried the add_months function?
    This would allow you to find the date a month before the given value, then you could truncate that to get the previous month. I haven't tested, but I assume the code would be something such as below:
    select trunc(add_months(to_date('15-08-2011','dd-mm-yyyy'),-1),'MON')
    from dual;
    01-JUL-11I don't know the layout of your tables, but hopefully this will help.
    Kerri
    Edited by: Kerri_Robberts on Aug 17, 2011 5:14 PM

  • Add 21 days to a date field in JSP

    Hi.
    How can I add 21 days to a String field containing a date value in JSP. I managed to get the string field without problem with the following codes :
    java.text.SimpleDateFormat formatdate = new java.text.SimpleDateFormat("dd-MMM-yy");
    java.util.Date currentTime_1 = new java.util.Date();
    String bDate = formatdate.format(currentTime_1);
    I would like to add 21 days to the field bDate.
    Please advice.
    Thanks.

    As far as I know we cannot manipulate on the formatted date i.e. on a string value. but you can add/deduct days from a date and then format
    it to get same result. you can try this out
    java.text.SimpleDateFormat formatdate = new java.text.SimpleDateFormat("dd-MMM-yy");
    java.util.Date currentTime_1 = new java.util.Date();
    Calendar cal = Calendar.getInstance();
    cal.setTime(currentTime_1);          
    cal.add(Calendar.DATE,21);          
    String bDate = formatdate.format(cal.getTime());          
    System.out.println("formatted date "+bDate);
    -Nagasree

Maybe you are looking for