Adding a interval to a date

I have the number of day and months that I want to add to a date in a number variable, how do I add it or how do I transform a number into an interval of that many months?
I have tried a few things without success:
Works with literals
SQL> select sysdate + interval '5' day from dual;
SYSDATE+IN
11.06.2008
but not with variables
SQL> declare
2 mnd number;
3 begin
4 mnd := 5;
5
6 select sysdate + interval 'mnd' day from dual;
7 end;
8 /
select sysdate + interval 'mnd' day from dual;
ERROR at line 6:
ORA-06550: line 6, column 29:
PL/SQL: ORA-01867: the interval is invalid
ORA-06550: line 6, column 3:
PL/SQL: SQL Statement ignored
SQL> declare
2 mnd number;
3 begin
4 mnd := 5;
5
6 select sysdate + interval mnd day from dual;
7 end;
8 /
select sysdate + interval mnd day from dual;
ERROR at line 6:
ORA-06550: line 6, column 33:
PL/SQL: ORA-00923: FROM keyword not found where expected
ORA-06550: line 6, column 3:
PL/SQL: SQL Statement ignored
Anyone able to give me a pointer?

That's not going to work in PL/SQL, like you have found out.
You can however add the number 5 of course, or use the numtodsinterval function:
SQL> declare
  2    l_number_of_days number := 5;
  3    l_new_date date;
  4  begin
  5    l_new_date := sysdate + interval l_number_of_days day;
  6    dbms_output.put_line(to_char(l_new_date,'dd-mm-yyyy hh24:mi:ss'));
  7  end;
  8  /
  l_new_date := sysdate + interval l_number_of_days day;
FOUT in regel 5:
.ORA-06550: Regel 5, kolom 36:
PLS-00103: Symbool "L_NUMBER_OF_DAYS" aangetroffen terwijl een van de volgende werd verwacht:
. * @ & = - + ; < / > at in is mod remainder not rem
<een exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec between || member
<een SQL-string tussen enkele aanhalingstekens> submultiset
Symbool "<een SQL-string tussen enkele aanhalingstekens> werd ingevoegd voor "L_NUMBER_OF_DAYS" om door te gaan.
SQL> declare
  2    l_number_of_days number := 5;
  3    l_new_date date;
  4  begin
  5    l_new_date := sysdate + 5;
  6    l_new_date := sysdate + numtodsinterval(5,'day');
  7    dbms_output.put_line(to_char(l_new_date,'dd-mm-yyyy hh24:mi:ss'));
  8  end;
  9  /
11-06-2008 14:14:09
PL/SQL-procedure is geslaagd.Regards,
Rob.

Similar Messages

  • Gettig error while adding a pdf file in Data Manager

    Dear All,
    When I m trying to add a new pdf file in the Data manger then it gives the error as:" Unable to open Adobe Acrobat. See your administrator about installing Adobe Acrobat."
    Please help me in adding this pdf file to Data Manager.
    Thanks And Regards
    Gaurav Kumar sharma

    Hi Gaurav,
    In order to load PDF files Adobe Acrobat® Standard or Professional Version is required and it needs to be installed on the machine that is loading the PDF and not on the Server machine.
    That's why it is giving you error to Install Adobe Acrobat. It is also required to generate Thumbnails.
    Refer, SAP Note for more details:
    https://websmp130.sap-ag.de/sap/support/notes/1258537
    Thanks and Regards,
    Mandeep Saini

  • Error Message while adding Item in Item Master Data- [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting the nvarchar value 's008 01' to data type int. (CINF)

    Dear Experts
    I am getting the following error message while adding item in Item Master data. I have modified the following SBO_SP_transactionNotification in SQL server after that could not able to add the item
    ALTER proc [dbo].[SBO_SP_TransactionNotification]
    @object_type nvarchar(20),                      -- SBO Object Type
    @transaction_type nchar(1),               -- [A]dd, [U]pdate, [D]elete, [C]ancel, C[L]ose
    @num_of_cols_in_key int,
    @list_of_key_cols_tab_del nvarchar(255),
    @list_of_cols_val_tab_del nvarchar(255)
    AS
    begin
    -- Return values
    declare @error  int                       -- Result (0 for no error)
    declare @error_message nvarchar (200)           -- Error string to be displayed
    select @error = 0
    select @error_message = N'Ok'
    --    IF @OBJECT_TYPE = '59' AND (@TRANSACTION_TYPE = 'A' or @TRANSACTION_TYPE = 'U')
      BEGIN
       IF EXISTS(
        SELECT T0.Price FROM IGN1 T0
        where  IsNull(T0.Price, '0') = '0' and T0.DocEntry = @list_of_cols_val_tab_del)
       BEGIN
        SELECT @ERROR=1,@ERROR_MESSAGE='Please insert the price !'
      END
    end
    -- Select the return values
    select @error, @error_message
    end

    Hi Rathna,
    Just put the SP like this, without the -- before the IF. A -- marks the line as a command therefore you need to uncomment and it will work.
    IF @OBJECT_TYPE = '59' AND (@TRANSACTION_TYPE = 'A' or @TRANSACTION_TYPE = 'U')
      BEGIN
       IF EXISTS(
        SELECT T0.Price FROM IGN1 T0
        where  IsNull(T0.Price, '0') = '0' and T0.DocEntry = @list_of_cols_val_tab_del)
       BEGIN
        SELECT @ERROR=1,@ERROR_MESSAGE='Please insert the price !'
      END
    end
    Hope it helps

  • While adding localization for appstore meta data, I cannot find the language Polish (Polski)

    While adding localization for appstore meta data, I cannot find the language Polish (Polski) under the option Choose another language: in iTunes connect.
    I am updating the app to a newer version. I need to show the App description etc in Polish too. But I can't fnd the Polish in the list of languages that can be
    added. Screen shot of languages is attached.
    Thanks.

    Hi,
    According to your post, my understanding is that you have an issue about adding attachments to list items in app.
    To add attachment to list item in the host web, we should first get the list and the list items from the host web, then add the attachments to the list items.
    There are two articles about retrieve the list and list items in the host web, you can refer to them.
    http://www.dotnetcurry.com/showarticle.aspx?ID=1028
    http://www.c-sharpcorner.com/UploadFile/93cb27/retrieve-sharepoint-app-host-web-list-items-in-sharepoint-ho/
    What’s more, we can also use the REST API to achieve the same scenario.
    http://www.c-sharpcorner.com/UploadFile/472cc1/add-attachments-to-list-items-in-sharepoint-2013-using-rest/
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • IPhone 4 won't slide to unlock . I tried everything possible and even got my phone replaced fora new one costing me 10,282 Rupees . The new phone is again having the same problem even without adding any apps or taking data backup

    iPhone 4 won't slide to unlock . I tried everything possible and even got my phone replaced fora new one costing me 10,282 Rupees . The new phone is again having the same problem even without adding any apps or taking data backup

    Yeah, first my thought was also that... that's why I've gone to Apple and they already switched the phone twice!!!
    Last time was yesterday... I posted this here because I came from Apple and with a new iPhone 5, although I didn't restore anything from iCloud, I hadn't even logged in to iCloud / AppStore, and without any event on the lockscreen my iPhone 5 was already "locked" on the unlock screen... after a mere 45m after I used it without a single App!! Just a couple of SMS / 1 or 2 calls... I'm going to Apple again on monday, but tried to post here to see if this has happened before to anyone with 3 new iPhones!!!

  • Adding new fields to Item Data - PO (ME

    Hi All,
    Is it possible to add new custom fields to PO Item Data in Confirmations tab and these new fields are required only in PO Change (ME22N).
    How can we achieve this!
    Can anybody provide feasible solution for the same!
    can anybody tell me if this is possible!
    Thanks in advance.
    Thanks,
    Deep.

    Hi All,
    Thanks for the reply.
    Can anybody confirm BADI ME_GUI_PO_CUST will acheive desired functionality for above posted issue!
    Functionality: Adding new custom fields to confirmation tab. During Inbound delivery in confirmation tab (Item data) if 'Confirmation category' is selected then the new custom fields should show up below for input & they can be saved.
    if 'Confirmation category' is not selected then new custom fields should be invisible.
    Thanks,
    Deep.
    Edited by: Deep on Jul 24, 2009 4:49 AM
    Edited by: Deep on Jul 24, 2009 5:05 AM

  • Adding new fields to the data flow

    Hi,
    I am currently planning to add some new fields in one DSO and map it (with info source) in the update rules.
    Will adding new fields to Info source - Comm. structure affect all the update rules connected to it?
    The info source is connected to multiple DSO.
    (The data source is currently under enhancement for these fields). Once this is done, we have to replicate it to BW.
    Thanks,
    Naveen

    yes.
    Once the enhancement is done for data source in r/3 side, you will have to replicate the datasource in BW.
    Adding new fields will deactivate the update rules. You have to map the same in update rule and activate the same.
    This will require activation of  transformations, update rules, etc for related DSOs. Try to find out the where used list for the DSO where you want to add the new objects. Then check each objects whether these are activate after the changes. If these are inactive, you will have to activate all the objects.
    Cheers
    Chanda

  • No time field in an event added by pressing down a date in the month view of the calendar!, no time field in an event added by pressing down a date in the month view of the calendar!

    I have been trying to add time to an event i already added but the time field does not exist.
    this happens only when I add the event from the month view while I press a date. in no other senario does this happens.
    may be its a bug in the calendar.
    if I press the + sign then it's normal.
    any suggestions on how to fix this?

    there is edit button; however, my problem comes after that. if the event was added using the above method then there is still no way to change the time of the event in that date. if the event was added in any other way then I can change the time.
    and I just realized my iphone3gs with ios5.0.1 has the same exact bug.

  • R12 Payment Process Request Status Report adding extra columns to XML data.

    In 11i, we had modified the Preliminary Payment Report to include extra columns ( invoice distributions). In r12 , that report is obsolete and Oracle introduced a new report "Payment Process Request Status Report". This request uses BI Publisher to generate the final report output. I am unable to modify the template since the XML output of the report does not
    contain the invoice distribution account data. We need to know how can we modify the XML data to include the extra columns.
    For Funds Disbursement Process ( Payment Instruction File) , Oracle provides IBY_FD_EXTRACT_EXT_PUB extensibility package to construct custom XML element structure that can be added to the payment XML extract generated by Oracle Payments. Do we have something similar for this report ? Are there any other options available ?
    Thanks

    Hi
    The same package "IBY_FD_EXTRACT_EXT_PUB" works for payment process request status report also. Please add the logic to get the distribution data in this package and you will see the new XML tags in this report also.
    Hope this helps.
    Vinit

  • Has anyone else had a problem with Verizon adding the free 1gb of data when you you orderd your iphone 6?

    So on the order, it clearly states that I would receive an extra 1 GB of data for two years when I bought the new iPhone.  I actually added two iPhone 6's to my account.  And each order stated the promotional data.  It did not automatically add when I activated the two new phones.  I have made 4-5 phone calls to customer service and I now have .488 GB of promotional data on my account.  I should have 2 GB...
    Anyone else have this issue and how did you get it resolved?

    I was running into the same problem with my Mac.  I could not open nor find an application that would open a .spdoc file extension.  However, I went to my iPad and was able to open the file using the Scanner Pro app.  I hope this helps.

  • Adding 1 day to a date in BPEL

    Hi,
    Im trying to add 1 day to a date in a BPEL proces. I saw that there was a xp20:add-dayTimeDuration-to-dateTime so I tried using this in several ways. I didnt expect the input variable to be a string. I tried converting my date to a string and adding 1 day like this:
    xp20:add-dayTimeDuration-to-dateTime(xp20:format-dateTime(string(bpws:getVariableData('inputVariable','payload','/ns1:GereedMeldenRoosterRequest/StartDatum')), 'YYYY-MM-DD'), 'P1D')
    But the variables which I try to fill stays empty. The element which I try to fill is of type dateTime. Is this maybe the error that add-dayTimeDuration-to-dateTime returns a string and it cannot cast it to dateTime?
    Can anyone tell me how to solve this properly?
    Thanks in advance!

    Hi,
    I refactored my expression to look like this:
    xp20:format-dateTime(xp20:add-dayTimeDuration-to-dateTime(bpws:getVariableData('inputVariable','payload','/ns1:GereedMeldenRoosterRequest/StartDatum'), 'P1D'), '[Y]-[M]-[D]')
    But the I receive an error: XMLElement cannot be cast to java.lang.String
    Then I tried:
    xp20:format-dateTime(string(xp20:add-dayTimeDuration-to-dateTime(bpws:getVariableData('inputVariable','payload','/ns1:GereedMeldenRoosterRequest/StartDatum')), 'P1D'), '[Y]-[M]-[D]')
    Because xp20:add-dayTimeDuration-to-dateTime needs a String as input and I dont know how getVariableData returned it but with this I get the error:Parse Error in string function
    Any ideas?

  • Adding Business Days to a Date to create New Date

    I am looking to add a formula to auto calculate a new date, but only want to count business Days.
    Currently I am using formula to calculate how many days need to be added:
    //ODD Priority Business Days
    If left ({DEFECT.PRIORITY}, 1)= "1" then 10    
    else  
    If left ({DEFECT.PRIORITY}, 1)= "2" then 20
    else
    If left ({DEFECT.PRIORITY}, 1)= "3" then 50
    else
    If left ({DEFECT.PRIORITY}, 1)= "0" then 10
    Now I need to create a formula to add these numbers to the date field, for conversation purposes, I need to add these business days to my "start date" to equil my "ODD date".
    Example, if my "start date" is 1/1/2009 and it is a Priority 2, then I need to add 20 business days to that, so the "ODD date" would be: 1/29/2009.
    Please help.

    Thank you Garrett Fitzgerald! Please see the modified formula which I meant
    {Startdate}
        + {@BusinessDays}
        - DateDiff("ww", {Startdate}, {Startdate} + {@BusinessDays}, crSaturday)
        - DateDiff("ww", {Startdate}, {Startdate} + {@BusinessDays}, crSunday)
    Regards,
    Raghavendra

  • Adding 30 days to a date in a dynamic LC form

    Hello-
    I'm working on a dymnamica form that is merged with XML data. In the XML, I get a FirstQuoteDate and bind it to the corresponding field in the form. I then have to calculate the ValidDate by adding 30 days to the FirstQuoteDate and display that date int he Valid Date field.
    I've tried several scripts with no luck. Below is the latest script I tried. I also tried the script in several different events. I believe it is the calculate event for the ValidDate field right now. Does anyone know what I am doing wrong?
    var QuoteDt = Date2Num(PROPOSAL.Page2Summary.FirstQuoteDate.rawValue, "MM/DD/YY")
    var FutureDt = QuoteDt+30
    var ValidDt = Num2Date(FutureDt, "MM/DD/YY")
    PROPOSAL.Page2Summary.ValidDate.rawValue = ValidDt

    What event should I be putting this script in? Am I thinking I can't put it in the Change event because the date isn't being entered through the form so the field never actually changes? Do I have to use a different event? The FirstQuoteDate and ValidDates are actually floating text fields in my form. I did find that example out there from a different discussion and have tried this script in the initialize event of the First QuoteDate field and it didn't work for me.
    ValidDate.rawValue = Num2Date(Date2Num(xfa.event.newText, "M/D/YYYY")+30,"MM/DD/YYYY");

  • Adding days to the current date

    I'm trying to write a program that takes an order and prints an invoice for my intro to java class. The date of the order and the date of arrival (which is 14 days after the date of the order) are to appear on this invoice. I thought that I figured it out but I get a compile error. Here's what I have so far:
    SimpleDateFormat formatDate = new SimpleDateFormat("MMMMM, dd, yyyy");
        Calendar rightNow = Calendar.getInstance();
        public String dateOfOrder()
             return formatDate.format(rightNow);
        public String dateOfArrival()
             return formatDate.format(rightNow.add(DAY_OF_MONTH, 14));
        }I'm writing it in JCreator and I get "cannot find symbol variable DAY_OF_MONTH" as my compile error. It compiled just fine until I added the dateOfArrival method. I keep reading through the Calendar API but I just can't understand why it won't work. What am I doing wrong?

    masijade. wrote:
    Which class is "DAY_OF_MONTH" a part of (I know what it is, but I want you to think on it). Try adding that class name to the front of the field name, with a period between them i.e.Calendar?
    I tried making the following adjustment but just got a new error.
    public String dateOfArrival()
             return formatDate.format(rightNow.add(Calendar.DAY_OF_MONTH, 14));
        }My error this time is: 'void' type not allowed here
    It seems like it is recognizing DAY_OF_MONTH now but something else is going wrong. Where am I going wrong?

  • Web sites won't recognize photos added to iPhoto since migrating data

    So, I'm stymied. I haven't seen a solution or question already asked that is precisely like my problem, so I thought I'd just ask it myself.
    A couple months ago, I did something to bork up the permissions in Lion - if I could be more specific I would. The solution as it eventually dawned on me and the actually really helpful guy at the Genius Bar, after trying literally everything possible besides wiping, was to just wipe the HDD and start over. So that's what I did. I used Time Machine to back up everything so that I could just import the data into the new programs, without simply copying everything over including preferences using Migration Assistant. Lo and behold, it fixed all my permissions problems. But now I have a new problem.
    Whenever I want to upload photos to a website, such as Flickr (or any other - I've tried many of them), photos added to my iPhoto '09 library after that migration happened do not appear in the Media browser window. Everything before the migration is there, but nothing after. This is not the case for pictures taken in Photo Booth, interestingly enough.
    I've verified and repaired disk permissions, I've cleaned out all the iPhoto plist files, both in Library/Caches and Library/App Support. I've opt+cmd started iPhoto and 1) rebuilt all thumbnails, and 2) examined and repaired iPhoto permissions. I've cleared out all the caches on all my browsers. Nothing has worked. I imagine upgrading to iPhoto '11 may help, but I'm not sure. I'm willing to give that a shot if it's the last option.

    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.  

Maybe you are looking for

  • Missing Menu bar items - last effort

    I've searched and read here and found no solutions, so I'm posting this as a final attempt. I'm working with a system new to me. It had OS 9 on it when I got it. I checked for firmware updates that might be needed and it seemed current, so I installe

  • Thinkpad A31 Ultrabay Plus release problem

    I have a Thinkpad A31 that I'm repairing - I removed the Ultrabay enclosure that the CD-ROM fits into. I've reinserted it and have issues with the eject lever. The release mechanism allows the eject lever to come out, but there is no resistance on th

  • Need Info On Picking

    Hello, For  deliveries the picking has to happen automatically.  Is there any standard process for this? Could some one give me some info on tis. Points rewarded. Regards, Krishna

  • How to establish the connection - Best Practice

    Following is my code for database connection import java.sql.Connection; import java.sql.DriverManager; import oracle.jdbc.driver.OracleDriver; public class DBConnect      private static Connection connection = null;      static           try        

  • Coloring an image through code

    Hey guys, With a basic knowledge of the iphone SDK by now I've been playing around with some code and as expected stumbled upon "a pretty hard to do" idea. I was wondering how to color the contents of an image through code. Basically something like t