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

Similar Messages

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

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

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

  • 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

    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.

  • 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

  • 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

  • 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

  • How to add days to a date value in SQL plus

    I would like to perform what ADD_MONTHS does, but for days.
    I have tried ADD_DAYS with no result. It sais it doesnt recognise the column.

    Subtracting two dates gives the number of days beteen them. So, adding or subtracting a number and a date will increment or decrementthe date by that number of days.
    If you really want a function, then:
    CREATE FUNCTION add_days (p_date IN DATE,
                              p_days IN NUMBER) RETURN DATE AS
    l_ret_dt DATE;
    BEGIN
       RETURN (p_date + p_days);
    END;and you would cal it like:
    SQL> SELECT sysdate, add_days(sysdate, 5) FROM dual;
    SYSDATE     ADD_DAYS(SY
    29-NOV-2005 04-DEC-2005However, a function is certainly overkill for something that can be done simply as:
    SQL> SELECT sysdate, sysdate + 5 FROM dual;
    SYSDATE     SYSDATE+5
    29-NOV-2005 04-DEC-2005TTFN
    John

  • How to add days to a DATE variable?

    Hi,
    I want to run a query based on my date variable with subtracting 7 days from it. Thanks.
    p_date DATE;
    Select * from table where theDate between to_date(p_date , 'yyyy/mm/dd') to_date(p_date - 7, 'YYYY/mm/dd');
    Thanks.

    If p_date is a DATE data type variable why are you using TO_DATE? It is, by definition, already a date.
    WHERE theDate BETWEEN (p_date-7) AND p_date;

Maybe you are looking for