Date Diff In a BETWEEN Gives a 00932?

Good morning. This seems like a simple problem, but I can't find a solution in the forum or on Google. Can some wise Oracle SQL guru point me in the right direction?
This is what I'm trying to do:
...X BETWEEN '01-JUN-2006' AND ('30-NOV-2009' - 162)...but this gives an ORA-00932 error, inconsistent datatypes: expected DATE got NUMBER. I don't understand this; adding or subtracting an integer from a date shouldn't change its type, and doesn't seem to in other circumstances. I tried this next:
...X BETWEEN '01-JUN-2006' AND ('30-NOV-2009' - INTERVAL '162' DAY(3))I can't say I'm impressed with the implementation of intervals. The number has to be formatted as a string? The default precision is 2?? Anyway, this errors with ORA-30081, invalid data type for datetime/interval arithmetic. This error seems to be very elusive, none of a dozen sites gave any helpful info, and this very forum claims to have no topics with "30081".
In other databases I could use something like this:
...X BETWEEN '01-JUN-2006' AND DATEADD('d', '30-NOV-2009', -162))...but I can't find such a function.
I could calculate the net value of the second date before passing it to the query, but that really shouldn't be necessary. This isn't complicated! Any ideas? I'm running on Oracle 9.2, if it matters.
- J

Hi,
Don't forget that all DATEs include hours, minutes and seconds. When debugging a problem with DATEs you should always display them.
ALTER SESSION  NLS_DATE_FORMAT = 'DD-Mon-YYYY HH24:MI:SS';will make the default display include hours, minutes and seconds.
If you don't specify hours, minutes or seconds, they default to 0.
Why is this important?
Say you want to find orders placed between February 4 and 6 (inclusive) this year.
A common mistake is to say:
WHERE     order_date     BETWEEN      TO_DATE ('04-Feb-2009', 'DD-Mon-YYYY')
               AND      TO_DATE ('06-Feb-2009', 'DD-Mon-YYYY')Knowing that "x BETWEEN y AND z" returns TRUE when x=y or x=z you might think the expression above includes February 6. Actually, it only include the first second of February 6, and excludes the other 83,999 seconds.
That is, the expression above is equivalent to:
WHERE     order_date     BETWEEN      TO_DATE ('04-Feb-2009 00:00:00', 'DD-Mon-YYYY HH24:MI:SS')
               AND      TO_DATE ('06-Feb-2009 00:00:00', 'DD-Mon-YYYY HH24:MI:SS')To include orders placed at any time on February 6, you can say:
WHERE     order_date     BETWEEN      TO_DATE ('04-Feb-2009 00:00:00', 'DD-Mon-YYYY HH24:MI:SS')
               AND      TO_DATE ('06-Feb-2009 23:59:59', 'DD-Mon-YYYY HH24:MI:SS')or add 1 day to the end date, and do not include that point. This last technique is often used with parameters, for example:
WHERE     order_date     >= TO_DATE (:from_date, 'DD-Mon-YYYY')
AND     order_date     <  TO_DATE (:to_date,   'DD-Mon-YYYY') + 1

Similar Messages

  • Date Diff Issues

    1. Subscriber – Employee Details has these three records
    2. Call Details  has these two records
    My main goal is to populate date diff in table 1 as 1 if "work order check in date" >= 3 of Aspect calender date from the 2nd table.
    The Problem i am facing is that the date diff in table 1 does not populate. I have come to an understanding that the issue is because of many t many relationship between table 1 and table 2. Is there a way to work around this?
    Date Diff formula - If(DaysBetween([Work Order Check In Date];[Base2]) >=3 ;1;0)

    Hi Akshay
    Did you try removing If condition and able to see the date difference result,if so is it working fine or not? If it is working fine use this result and define another variable for If-else and validate the condition
    Regards
    Bose

  • Software to transfer data over Wi-fi between Laptop-Lap​top and Laptop-And​roid Phone

    Hello everyone !
    My name is Gaurav, i am  from Vasco, Goa. i need Software to transfer data over Wi-fi between Laptop-Laptop and Laptop-Android Phone  for My HP15-D103TX notebook PC. I am  not getting anywhere on google..
    please give me link of software to download, which should be compactible with my laptop.. also the apk file for android phone
    Operating system: Windows 8.1 x64

    @Gaurav1994 
    Thank you for using HP Support Forum. I have sent you a private message. If you’re unsure how to check your private messages please click here.
    Thank you,
    Omar
    I Work for HP

  • Define Shipping Data for Stock Transfers Between Storage Locations

    Hi Guru,
    Can i know what is the purpose to maintain Customer, SHipping data for each storage location for the STO between storage location?
    Purchasing --> Purchase Order -->
    Set up Stock Transport Order-->
    Set Up Stock Transfer Between Storage Locations-->
    Define Shipping Data for Stock Transfers Between Storage Locations

    The Sales org, Distribution channel, Shipping point, Vendor and Customer are maintained to created the delivery.
    It is for the transfer of stock between storage locations with any movement type.
    Eg: When you do a 311 movement type from Sloc A to Sloc B, then it will create a inbound delivery with the Vendor specified for Sloc A and an outbound delivery from Sloc B with the Customer specified assuming the customer and the vendor as the Plant.
    You have to create a internal Vendor and Customer.
    Hope it helps.

  • Data transfer i happening between SAP CRM & PI portal,

    Hi Experts,
    How is the data transfer i happening between SAP CRM & PI portal,
    how many ways it has been done ,Please explain the my query.
    Idoc wil be doing this functionality?
    Thanks & Regards
    Prajith P
    Edited by: Prajith Prabhakara on Aug 12, 2011 7:51 AM

    - Web Services Description Language (WSDL)
    - XML provides the common syntax for representing data.
    More info, refer
    [http://wiki.sdn.sap.com/wiki/display/ABAP/Web+Services]
    [http://wiki.sdn.sap.com/wiki/display/XI/SAPXIQuestionsAndAnswers]
    [http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c018da90-0201-0010-ed85-d714ff7b7019]
    Good day..!
    Cheers, Satish

  • Date prompt with a between statement

    Can a dashboard support a date range prompt? We are trying to make a prompt and use a between statement. Suggestions?

    I think you are using the prompt from the Prompt tab in Answers. What you need to do is use Dashboard prompts.
    Although Dashboard prompts have a "between" operator," if you use the 'between" operator, the ability to save the selections to Presentation Variables (PVs) disappears. When I need a "between" dates type prompts, I do the following:
    1) Create two Dashboard prompts set to PVs, say StartDate and EndDate. (In the Edit Formula area, use a CASE stmt on the column chosen -- doesn't matter what the column is -- so no action is performed on the column) (e.g., CASE WHEN 1=0 THEN ColumnName.TableName ELSE 'TEST' END)
    2) Change control to "Edit Box" so users can input the dates. (If you select two appropriate date columns, you can use the "Drop-down List" option and have the user select a valid date. In that case, you wouldn't use the CASE statement in step 1.)
    2) In your report, filter on the date column, convert the filter to SQL, and type in the following:
    +"Column name"."Table Name"+ BETWEEN '@{StartDate}' AND '@{uEndDate}'
    3) Place both the prompts and the report on a dashboard and when a start and end date is selected, the "between" function is performed on the report.
    HTH,
    Edited by: LC143 on Sep 3, 2008 9:52 AM

  • What is Data conversion ? What are data conversion programs ? please give

    What is Data conversion ? What are data conversion programs ? please give me some sample code?

    Hi,
    I think you mean "Data Acquisition"...
    "The Data Acquisition IT process allows you to connect heterogeneous sources (SAP systems, database management systems, files, relational data, multidimensional data) to BI. You can transfer data straight into BI from the source or use SAP NetWeaver XI to transfer data. Furthermore, the process supports direct access to source data, without having to load it into BI."
    http://help.sap.com/saphelp_nw04s/helpdata/en/aa/1fb042e745ca6ae10000000a155106/frameset.htm
    [Data AcquisitionTechniques in SAP NetWeaver BI|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/329fcd87-0c01-0010-4a9c-86f038e11d23]
    Regards
    Andreas

  • Date diff calculations

    I want to calculate the date diff for delivery date(eg;-sep-24 ,2007) and scheduled date(eg:-sep-17,2007)there the result should be 7 but i dont no how to write query can we use routines in this kind of situations...

    hai
    use replacement path for both dates and create a new formula by subtracting from(delivery date -scheduled date)
    below is the best example
    http://www.sd-solutions.com/documents/SDS_BW_Replacement%20Path%20Variables.html
    chk these links would help u more,
    http://help.sap.com/saphelp_nw04/helpdata/en/3f/89533e5ff4d064e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/2c/78a03c1178ad2ce10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/af/809528939d5b4fbff7e16a5bdc0d85/content.htm
    http://help.sap.com/search/highlightContent.jsp
    http://help.sap.com/saphelp_nw04s/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm

  • How to get diff of days between 2 dates

    Hi,
    I have a given date . I am looking for a simple way to get the difference of days between the 2 date like :
    currentDay - givenDate Day > 20 .
    I am using calendar for this. MyCode:
    java.util.Calendar calendar1 = Calendar.getInstance();
    calendar1.set(2003, 08,16);
    int userCreatedDay = calendar1.get(Calendar.DAY_OF_YEAR);
    java.util.Calendar calendar2 = Calendar.getInstance();
    int currDay = calendar2.get(java.util.Calendar.DAY_OF_MONTH);
    int currYear = calendar2.get(java.util.Calendar.YEAR);
    int currMonth = calendar2.get(java.util.Calendar.MONTH);
    int days= currDay - userCreatedDay;
    System.out.println("currDay:"+currDay+",createDay:"+userCreatedDay);
    System.out.println("Days left:"+currDay - userCreatedDay);
    if(days > 14) return true;
    o/P:
    currDay:266,createDay:249
    Days left : 17
    If i calculate today diff of days in only 7. I am not able to understand why the result is being displayed as 17.
    Is there anything wrong i am uisng this class.
    Please, help

    Personally, I do not like using the calendar class for this sort of thing. Why? Weel lets look at two simple dates: 4th of July 1777 and 21st March 2003.
    So I would create 2 GregorianCalendar objectsGregorianCalendar independenceDay = new GregorianCalendar (1777, 6, 4);
    GregorianCalendar startOfIraqWar  = new GregorianCalendar (2003, 2, 12);Now what do these contain? Well, here is the output (cut down for clarity)...
    independenceDay = [time=?, YEAR=1777,MONTH=6,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,
                       DAY_OF_MONTH=4,DAY_OF_YEAR=?,DAY_OF_WEEK=?,
                       DAY_OF_WEEK_IN_MONTH=?]
    startOfIraqWar = [time=?, YEAR=2003,MONTH=2,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,
                       DAY_OF_MONTH=12,DAY_OF_YEAR=?,DAY_OF_WEEK=?,
                       DAY_OF_WEEK_IN_MONTH=?]
    So what don't I like? All the useful fields are not filled in. They ***could*** be calculated by the constructor, but they aren't, particularly things like DAY_OF_YEAR, which would ease calculation enormously.
    What I would really like to see in GregorianCalendar is a diff() method which takes a GregorianCalendar as its argument and returns a time difference. In fact, you may want several, or an additional argument daying how you want the diff returned (days, years, seconds).

  • Calculate the date diff

    Hi, The requirement is to calculate the diff between 2 date fields and display it. I could able to get the difference between the 2 date fields. But now the result column SHOULD DISPLAY the result ONLY if the 2 date fields have the date set ELSE it should be left blank(basically NULL shud be set to the result column in such cases).
    The formula which I have used to get the result is :
    (NOERR(date1)<>0 AND NOERR(date2)<>0)*(date1-date2).
    The above formula works fine and gives the result as desired except that it puts "0" even though the date fields doenst have a value.I have tried to use the ELSE part by giving "1/0" thinking it wud give me "#" but this didnt help me out anyway.
    Any inputs on this...

    Thanks for the response.
    That was an option which I also thought of and I wud use it only as a last rescue and trying if I can get some info to do it otherwise.
    The other option which I have in my mind is to just get this diff into the cube and this shud resolve but then again I hv to chg the BW structures and unnecessarily I wud be increasing the load to the cube.
    Any other option in Bex ...???

  • Date Diff in Oracle BAM

    Hi, I need to get the difference between two dates (in days) in a calculated field, can anyone help me?
    Best Regards

    (Date1-Date2)/86400 should give you the time difference in days. 86400 is the number of seconds in 1 day.

  • Date diff

    Hi,
    I went through a lot of date related post and was able to write a script(with alps help-Re: Days behaviour between two dates Now iam using 11.1.2.1 planning on top of essbase. While my end date is saved as a sub var with value 20131231. the beginning date is a user input in data forms in planning. I used the member that hold this date value in the script but it doesnt do the calculation. No value is getting populated as output. the script is working , as ive tested it with two sub vars instead of user input.
    But i came across posts that spoke about difference in format that dates gets saved for essbase and planning. the date that i enter in planning reflects as "2.0130405E7" in essbase when i retrieve .
    Please do help.
    thanks

    Hi Alp,
    Am sorry for replying late. Here s waht my situation. The Year end date wd be saved as subvar in essbase, value =20131231. Project end date would be a date value fed from planning data forms to a account member of type date. Ive took help from one of your post and just inputted my values as you can see below.
    var y1, y2, m1, m2, d1, d2, difx1, difx2,diff,a,b,x;
    SET CREATENONMISSINGBLK ON;
    SET CACHE HIGH;
    Fix(&Curr_Year,"Actual","HSP_InputValue","No Employee","No Product","1st Pass","GL_Load","No Line Item","No Asset","No_Custom1","Jan")
    Fix("50")
    FIX("01-03-390")
    "Depreciation-IT HW"
    y1=@ROUND("Project End Date"/10000,0);
    y2=@ROUND(&YearEnd/10000,0);
    m1=@ROUND(("Project End Date"-y1*10000)/100,0);
    m2=@ROUND((&YearEnd-y2*10000)/100,0);
    d1="Project End Date"-(y1*10000+m1*100);
    d2=&YearEnd-(y2*10000+m2*100);
    difx1=@TODATEEX("mm/dd/yyyy",@JconcatStrings(@LIST(@JgetStringFromDouble(m2),"/",@JgetStringFromDouble(d2),"/",@JgetStringFromDouble(y2))));
    difx2=@TODATEEX("mm/dd/yyyy",@JconcatStrings(@LIST(@JgetStringFromDouble(m1),"/",@JgetStringFromDouble(d1),"/",@JgetStringFromDouble(y1))));
    diff=@datediff(difx2,difx1,DP_DAY);
    "Depreciation-IT HW"=@ROUND(diff*("165012"/1095),0);
    "Total Budget required"
    "Total Budget required"="Fit Out Cost"+"165012"+"165007"+"165017";
    endfix;
    endfix;
    endfix;
    The rule started working fine, for dates i inputed through the data form, taking value of Project End date. But since it was just under testing i had Fixed it for Jan alone. Then when i included other months it started to fail saying Error in date formatting. And then a few times i went back and saw the rule run for Jan but later it stopped for all.
    the value of project end date gets saved in essbase as 2.0130131E7. But in planning when i check for raw data it shows 20130131, so i thought the rule was logically fine.
    please do direct me in the right way.
    thanks,

  • Finding date diff

    Hi friends,
    I'm having doubt in time diff. Just assume this scenario.
    Today is sunday and 13 hrs. I just want to know the difference between this and coming wednesday 01 hrs. But i don't know the date for coming wednesday. Is there any function available which returns the date for this coming wednesday. And i don't want to add 3 to the DAY_OF_MONTH part.

    Today is sunday and 13 hrs. I just want to know the
    difference between this and coming wednesday 01 hrs.
    But i don't know the date for coming wednesday. Is
    there any function available which returns the date
    for this coming wednesday. And i don't want to add 3
    to the DAY_OF_MONTH part.Your loose specification makes it difficult to be sure what you want but try this.
        public static void main(String[] args)
            // Now
            GregorianCalendar calendar = new GregorianCalendar();
            long nowInMilliseconds = calendar.getTime().getTime();
            // Move on to next wednesday
            while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.WEDNESDAY)
                calendar.add(Calendar.DAY_OF_YEAR, 1);
            // Set to 1 am
            calendar.set(Calendar.HOUR_OF_DAY, 1);
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MILLISECOND, 0);
            // Difference in ms
            long betweenNowAndNextWednesday = calendar.getTime().getTime() - nowInMilliseconds;
            System.out.println(betweenNowAndNextWednesday + " " + calendar.getTime());
        }It should not be too dififcult to generalise it!

  • Extending DataFinder to include Non-Data Entries and Relationships Between Entries

    I am trying to create custom data centralization and management software for our lab with DataFinder Toolkit.  In addition to storing data from data acquisitions, I want to be able to store additional information with the data such as images, pdf files, word documents that can be easily accessed after finding the data.  My current idea is to handle external files by storing the filepath in a property of an object vs trying to store the data itself in the datafinder database.  My code would know how to open these files so the user can see them with external software or a custom labview app.
    I also want to be able to store non-data objects such as an object that describes a piece of test equipment or a sample through properties and external files.  Images and documents are again important here.  And then create relationships through unique barcoded IDs that are a property in the datafinder entry.  So not only could I look at the data, I could find information about the samples and lab equipment. Or anything else we think needs to be saved.
    The code I am writing around DataFinder would be in charge of maintaining the unique IDs and know how the relationships between those IDs work to generate the proper queries. Like a 'Get Test Equipment Used' button next to a search result.
    For the external non-data objects I was going to use Labview code to create a file with all the information about the object (unique ID, properties and external file paths) and create a plug-in so the datafinder will index the file and make it searchable.
    Does this seem reasonable? I like the idea of working with one system and having everything update based on adding, deleting and modifying files in a folder. Also, I like the idea of not splitting the data management up into multiple technologies and having to make those work together.
    Solved!
    Go to Solution.

    From the description, you've given the system seems plausible. The non-data elements you discussed when broken down are just additional data to associate with an object.  Storing file paths seems plausible as done in the community example below:
    Execute String/Numeric Querry Using Data Finder Toolkit
    https://decibel.ni.com/content/docs/DOC-10631
    Regards,
    Isaac S.
    Regards,
    Isaac S.
    Applications Engineer
    National Instruments

  • Can Data Links be established between Data sets based on View Objects?

    Hi all,
    In the BI Publisher Documentation it's given that Datasets based on view object queries do not support Data Links / Group Links. We found out that only way to establish relationship between view object Datasets is to create a view link and then upload it to create a Dataset.
    1. Is there any other way to establish relationship between view objects Datasets in DataModel editor itself just as in the case of data sets based on (SQL queries e.t.c.)?
    2. If so can View object Datasets be linked to Datasets based on other Datasources?
    3. Will the Datalinks for View object Datasets be supported in any of the upcoming releases. Is there any ER logged for this case?
    Any insight on the above issues will be really helpful.
    Thanks

    Enhance the data source with date and time and populate these fields in the user exit using the function module IB_CONVERT_FROM_TIMESTAMP .
    OR
    You can create Z function module IB_CONVERT_FROM_TIMESTAMP in BW side and write a routine in update rules/transfer rules to populate date and time.
    hope this helps ...
    Ravi

Maybe you are looking for