Compare Date in Expression Builder

Hallo,
I'm trying to build the following sql:
select * from (select * from TABLE1 where CODE =#myCode AND EFFECTIVE_DATE <=#myDate AND EFFECTIVE_DATE >=
ADD_MONTHS(#myDate,(-1)*#ageMaxMonth) ORDER BY EFFECTIVE_DATE DESC ) WHERE ROWNUM < 2
Vector args = new Vector();
args.add(myCode);
args.add(myDate);
args.add(ageMaxMonth);
ExpressionBuilder expBuilder = raq.getExpressionBuilder();
Expression exp = expBuilder.get("myCode").equal(expBuilder.getParameter("myCode"));
exp.and(expBuilder.get("effectiveDate").lessThanEqual(expBuilder.getParameter("myDate")));
exp.and(expBuilder.get("effectiveDate").greaterThanEqual(expBuilder.getParameter("myDate").addMonths(ageMaxMonth.intValue() * -1)));
raq.setSelectionCriteria(exp);
raq.addDescendingOrdering("creationDate");
raq.addArgument("myCode");
raq.addArgument("myDate");
raq.addArgument("ageMaxMonth");
// Include rownum
raq.setFirstResult(1);
raq.setMaxRows(1);
raq.setRedirector(new OracleRowNumRedirector());
Vector vectors= (Vector) uow.executeQuery(raq, args);
The request ist not working. Im get the entries where the effectiveDate EFFECTIVE_DATE <=
ADD_MONTHS(#myDate,(-1)*#ageMaxMonth)
Thanks
Edited by: user11344339 on 25.01.2013 00:25

cdelahun wrote:
It maybe a cut and paste error, but the code shown is not setting exp to the new exp:
exp =exp.and(expBuilder.get("effectiveDate").lessThanEqual(expBuilder.getParameter("myDate")));
exp = exp.and(expBuilder.get("effectiveDate").greaterThanEqual(expBuilder.getParameter("myDate").addMonths(ageMaxMonth.intValue() * -1)));
raq.setSelectionCriteria(exp);
If this is not a cut and paste error, it would result in the effectiveDate range restriction not being included in the where clause at all.Hello,
Thanks, this was a part of the problem. the generated SQL is now Ok and the query is working for the object already persisted in the Database.
But for the Objects in the cache I’m still get records where the ‘effectiveDate’ <= ADD_MONTHS(mydate, ageMaxMonth *-1)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • How to use TRUNC function with dates in Expression Builder in OBIEE.

    Hi There,
    How to use TRUNC function with dates in Expression Builder in OBIEE.
    TRUNC (SYSDATE, 'MM') returns '07/01/2010' where sysdate is '07/15/2010' in SQL. I need to use the same thing in expression builder in BMM layer logical column.
    Thanks in advance

    use this instead:
    TIMESTAMPADD(SQL_TSI_DAY, ( DAYOFMONTH(CURRENT_DATE) * -1) + 1, CURRENT_DATE)

  • Increasing date through Expression builder?

    Hi,
    we have requirement of validating the date range.
    The date entered should not be greater that 3 days of current(todays) date and min date should be be less that last three days.
    I am using Daterangevalidator and i need to know how to set a EL expression to satisfy the above condition.
    we have a current date in El coming from "#{bindings.startedDate.inputValue}" now i just want to know how to increase and decrease the days using EL.
    <af:validateDateTimeRange
    maximum="#{bindings.startedDate.inputValue + 3}"
         minimum="#{bindings.startedDate.inputValue - 3}"
    The above code is not working.
    Edited by: user11285758 on Apr 25, 2013 7:45 PM

    Thanks for your reply.....
    When I put above code
    <af:validateDateTimeRange
    maximum="#{bindings.startedDate.inputValue + 259200000}"
    minimum="#{bindings.startedDate.inputValue - 259200000}" />
    and deploy the application to server. page is failing while loading at that particular code. Please find error below
    ERROR:
    ]] Root cause of ServletException.
    java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key el.convert
    at java.util.ResourceBundle.getObject(ResourceBundle.java:393)
    at java.util.ResourceBundle.getString(ResourceBundle.java:353)
    at com.sun.el.util.MessageFactory.getArray(MessageFactory.java:86)
    at com.sun.el.util.MessageFactory.get(MessageFactory.java:66)
    at com.sun.el.lang.ELArithmetic.coerce(ELArithmetic.java:384)
    Truncated. see log file for complete stacktrace
    Any idea what needs to be done to fix the issue?
    Edited by: user11285758 on Apr 28, 2013 9:38 PM
    Edited by: user11285758 on Apr 28, 2013 9:39 PM

  • Compare only DATE portion of a datetime field in Expression builder

    Hi! All,
    This may be a simple question, but I couldn't find the answer. I have a query where I want to say :
    Expression exp = exp1.get("startDateTime").equal(pDate);
    here pDate is a java.util.Date class with a time stamp.
    I wish to basically compare just the DATE portion of the value stored in the data base with only the DATE portion of "pDate" and ignore the time component.
    How do I do this in expression builder?
    By the way we are on Toplink 9.0.4.5
    Thanks

    There are a couple of ways to accomplish this. You could use between(beginningOfDay,endOfDay) where beginning of day is 12:00:00am on the date specified in pDate and end of day is 11:59:59pm on pDate. Or you could consider using a combination of dateName(), datePart(), and/or truncateDate() expressions to compare at the day, month, year level. I am not sure which would give you better performance, so you might need to do some testing to verify.
    In the first case, create beginningOfDay and endOfDay based upon the date housed in pDate. Then:
    Expression selectionCriteria = exp1.get("startDateTime").between(beginningOfDay,endOfDay);
    In the second case, there would be a little more code to write:
    Expression startDateTimeExp = exp1.get("startDateTime");
    Expression dayExp = startDateTimeExp.datePart("day");
    Expression monthExp = startDateTimeExp.datePart("month");
    Expression yearExp = startDateTimeExp.datePart("year");
    int desiredDay = get day of month from pDate;
    int desiredMonth = get month of year from pDate;
    int desiredYear = get year from pDate;
    Expression selectionCriteria = dayExp.equal(desiredDay).and(monthExp.equal(desiredMonth)).and(yearExp.equal(desiredYear));
    Check out the TopLink API docs on the Expression class for more details on what these Expression building methods do : http://download-west.oracle.com/docs/cd/B10464_05/web.904/b10491/index.html
    Hope that helps,
    Doug

  • Max date by month in expression builder

    Hello
    I'd need to create a new logical column and use the expression builder to make this column return only the last day of each month. I know at answers level I can write something like this in the formulas: Max(Date by month). However I can't do that in expression builder as it doesn't like the word 'by'..
    Is there a way to get it done?
    Thanks in advance!

    Hello,
    The max(date) should work in logical layer. As when you pull in month it automatically groups by month.
    thanks,
    deep

  • FILTER EXPRESSION COMPARING DATA TYPES

    Hi,
    I am recieving an error when running my report. I added a filter expression to my chart which only shows data > 24 hours but I am receiving the following error... can anybody help me?
    CANNOT COMPARE DATA OF TYPES SYSTEM.DECIMAL AND SYSTEM.DOUBLE

    Hi Irj1985,
    Based on the error message, we can know that the data type of the two values are different. One of them is decimal, another of them is double.
    To trouble this issue, please refer to the steps below.
    Ensure that the issue was cause by the filter.
    Convert the data type of one of the value to the data type of another value.
    If the issue persists, please elaborate the issue, provide the detail information about the fitler and your report, so that we can make further analysis.
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to compare data cross 2 different tables in logical layer?

    Hello
    I have run into a situation where I need to bring in a new column from the status table say 'flag'. This physical column then needs to compare itself with the sales fact's code column. So if the code is '100' and above, then flag column should be '0', else flag.
    In the data models, the sales fact joins to status dimension physically and logically.
    So in the expression builder of the flag column in my BMM layer, I have something like *(case when Sales Mart. Sales Fact. status > '100' then '0' else Sales Mart. Sales Fact. flag end)*..
    However, although the syntax is correct in the expression builder, however the logical column doesn't accept that expression via 'invalid expression'.
    I think I know the problem, because flag column and status column are from different physical and logical column therefore it can't be used in the case statement at logical level. Because I tested this theory with '*(case when Sales Mart. Sales Fact. status > '100' then '0' end)'* and it accepted it.
    Nonetheless, I can't modify the database table nor the ETL to put both columns in one table, nor am I allowed to defined such expression at answers.
    Is there a way I can base the result of flag column on the data of status column from a different logical table?
    Please advice!
    Thanks

    Follow these steps:
    1) Bring your first time period in your main report.  This will be your first query.
    2) Bring your second time period in a subreport.  This will be your second query.
    3) Bring the values from your subreport into your main report using shared variables.
    4) Lastly, compare the results using formulas in your main report.
    I hope this information proves useful.
    Regards,
    Zack H.

  • Expression Builder: convert string to number

    Hi all,
    I'm having trouble building a field validation rule for bank account numbers.
    The numbers have 12 positions, so I cannot use a string or text number.
    The validation rule to be implemented is that the last two digits are calculated based on the first 10 (modulo 97).
    However, when I use the Mid function to pick the first characters, I am unable to do any calculations on it. Apparently, the string to number conversion doesn't work (it should work when I read the manual, as it says that when using an operator between two data types, the second type is converted to the first (cf. example of 1234+abcd (should result in 1234 as to the manual))). So I tried '1*Mid(...)' or '0+Mid(...)'. Syntactically the expression builder accepts it and I can save it. BUT when I change the particular value on the screen, it gives me an SSO error (not the Field Validation error message I entered).
    Why isn't there simply a function ToNumber (like ToChar)????? How could I workaround this?
    Any input very welcome!
    Frederik

    Apparently, I was a bit confused when typing the first sentence, it should be:
    The numbers have 12 positions, so I cannot use an integer or number data type, but have to use String.

  • Logical SQL about Expression Builder

    Dear all
    I am Michel.
    When I was always trouble,
    everyone will go to support this Forum, I am glad.
    I want to fix Logical SQL about Expression Builder of Oracle BI 11.1.1.3.
    In detail, Business each year, fiscal year you want to make is to display
    the beginning of the fiscal year of April 1, always, the data,
    "OUTPUT_DATE" from April until March the following year.
    Currently being output error is as follows.
    :[nQSError: 22020] Function Subtring ( argument 1) does not support non-text types. (HY000)
    I want to fix logical SQL is as follows.
    case when substring("app_support"."TABLE_NAME"."OUTPUT_DATE" from 4 for 5)
    in ('04','05','06','07','08','09','10','11','12')
    then Cast
         Concat
    Substring(
                   Cast(
                        "app_support"."TABLE_NAME"."OUTPUT_DATE" AS char
              FROM 4 for 8
         '04-01'
    AS DATE
    when substring("app_support"."TABLE_NAME"."OUTPUT_DATE" from 4 for 5)
    in ('01','02','03')
    then timestampadd(SQL_TSI_YEAR,-1,
         Cast
         Concat
              Substring(
                   Cast(
                       "app_support"."TABLE_NAME"."OUTPUT_DATE" AS char
                   FROM 4 for 8
              '04-01'
    AS DATE
    For reference, logical SQL follows,
    there is no error, and it is operating normally.
    Cast
         Concat(
              Substring(
                   Cast(
                        "app_support"."TABLE_NAME"."OUTPUT_DATE" AS char
              FROM 0 for 5
         '-01')
    AS DATE
    I will grad to reply message.
    Thanks and regards.

    Dear Fame and all
    Hello.Thanks you for reply.
    Hi,
    You Missed END key word in the statement.Sorry,I mistake copy & paste only.
    So,The problem is still not resolved.
    The following shows, that the error has been corrected in the first message.
    Dear all
    I am Michel.
    When I was always trouble,
    everyone will go to support this Forum, I am glad.
    I want to fix Logical SQL about Expression Builder of Oracle BI 11.1.1.3.
    In detail, Business each year, fiscal year you want to make is to display
    the beginning of the fiscal year of April 1, always, the data,
    "OUTPUT_DATE" from April until March the following year.
    Currently being output error is as follows.
    :[nQSError: 22020] Function Subtring ( argument 1) does not support non-text types. (HY000)
    I want to fix logical SQL is as follows.
    case when substring("app_support"."TABLE_NAME"."OUTPUT_DATE" from 4 for 5)
    in ('04','05','06','07','08','09','10','11','12')
    then Cast
    Concat
    Substring(
    Cast(
    "app_support"."TABLE_NAME"."OUTPUT_DATE" AS char
    FROM 4 for 8
    '04-01'
    AS DATE
    when substring("app_support"."TABLE_NAME"."OUTPUT_DATE" from 4 for 5)
    in ('01','02','03')
    then timestampadd(SQL_TSI_YEAR,-1,
    Cast
    Concat
    Substring(
    Cast(
        "app_support"."TABLE_NAME"."OUTPUT_DATE" AS char
    FROM 4 for 8
    '04-01'
    AS DATE
    end
    For reference, logical SQL follows,
    there is no error, and it is operating normally.
    Cast
    Concat(
    Substring(
    Cast(
    "app_support"."TABLE_NAME"."OUTPUT_DATE" AS char
    FROM 0 for 5
    '-01')
    AS DATE
    I will grad to reply message.
    Thanks and regards.

  • How to use SQL OVER and PARTITION BY in OBIEE Expression Builder??

    Hi there,
    I want to create a new logical coulmn with the following SQL query.
    SUM(Inventory Detail.Qty) OVER(PARTITION BY Inventory Detail.A,Inventory Detail.B,Item.C,Inventory Detail.D,MyDATE )/SUM(Inventory Detail.Qty) OVER(PARTITION BY Inventory Detail.A,Inventory Detail.B,Item.C )
    How to use the OVER and PARTITION BY in OBIEE Expression Builder??
    Thanks in Advance

    hi bipin,
    We cant use by in Expression builder(rpd) .But use the same formula like this in Fx of answers
    SUM(Inventory Detail.Qty) OVER(PARTITION BY Inventory Detail.A,Inventory Detail.B,Item.C,Inventory Detail.D,MyDATE )/SUM(Inventory Detail.Qty) >OVER(PARTITION BY Inventory Detail.A,Inventory Detail.B,Item.C )SUM(Inventory Detail.Qty by Detail,ITEM,Mydate)/SUM(qty by detail,item)
    First check the numerator whether it was giving correct results or not then go with denominator
    compare the results with sql that u have
    Let me know if that does work
    thanks,
    saichand.v
    Edited by: Saichand Varanasi on Jul 27, 2010 9:27 PM
    Edited by: Saichand Varanasi on Jul 27, 2010 9:28 PM

  • Object type mappings in expression builder

    Hi,
    I'm trying to use expression builder to give me a query returning all instances of an object with a particular foreign key, and where 'active' = true.
    'active' is a CHAR field in the database with values 'T' or 'F' and this is mapped to a Boolean in workbench as true and false.
    All works fine in normal operations, retrieving and writing the data.
    I've written the expression as
    myId EQUAL arg
    AND
    active EQUAL 'true'
    where 'true' is a literal of type Boolean.
    Unfortunately, running this query generates an error that no mapping exists for 'true'.
    I've also tried changing it to
    active EQUAL 'T'
    where 'T' is a literal of type String.
    This also generates an error.
    It seems to me as though the object type mapping is confusing the expression builder and it can't generate the sql correctly.
    Any ideas?

    Can you post the specific version of TopLink, the exact code you are using to construct and execute your query, as well as the error message with stack trace. With these items we should be able to provide an answer for you.
    Doug

  • Validate Filter in Expression Builder of a Join Node

    Validating a filter query in the expression builder of a Join Node seems to take abnormally long.
    I'm mining a star schema with 1 fact table (750million rows) and 4 dimension tables. The join node merges facts and dimensions on a subset of the data that is specified in the filter query. The query is pretty simple:
    SUBSTR("L_PRESCRIBABLE_ITEM"."BNF_CODE" , 1,7 ) IN ('0601011','0601012')
    AND "L_LAST_DAY_TIME"."CALENDAR_YEAR" = '2010'
    When I press 'validate' it takes about 20 minutes to validate the syntax. When this completes successfully, when I press the OK button to get back to the Join Node, it seems to validate it for a second time, again taking about 20 minutes to complete.
    Is this something to do with the validation doing its processing on the raw data (i.e. the 750m rows x 4 dimension tables), rather than simply validating the structure of the query syntax? If so why is it doing it twice (not inculding the time taken to actually run the node).
    Cheers
    Brad
    Using Data Mining in SQL Developer 3.0.04

    Hi Brad,
    Actually the EA2 has an improvement but the final fix which uses strictly a parse validation, will be not be out till the next SQL Dev 3.1 release after EA2.
    Thanks, Mark

  • Less Than operator not working, Greater Than operator works comparing dates

    I need to compare dates to conditionally display a row. If the DateDueJulian_ID5<= AsOfDate_ID47 display otherwise don't. I get all rows but if I reverse the logic >= the condition works and only displays the one matching row.
    I am using the Template Builder 10.1.3.4.1 and WORD 2007.
    Any help is appreciated!
    Thanks
    XML Source:
    <Header_Section_S3>
    <Delinquency_Report_ID225>DELINQUENCY NOTICE</Delinquency_Report_ID225>
    <VersionName_ID270>0001</VersionName_ID270>
    <Report_or_Video_Title_ID53></Report_or_Video_Title_ID53>
    <Remit_To_Text_ID68>Remit To:</Remit_To_Text_ID68>
    <RemitToAddressLine1_ID2>XXXXX</RemitToAddressLine1_ID2>
    <XX_XX_XX_ID259>2010-08-25</XX_XX_XX_ID259>
    <Date__ID258>Date</Date__ID258>
    <RemitToAddressLine2_ID5></RemitToAddressLine2_ID5>
    <RemitToAddressLine3_ID8></RemitToAddressLine3_ID8>
    <As_of_Date__ID46>As of Date</As_of_Date__ID46>
    <AsOfDate_ID47>2007-11-29</AsOfDate_ID47>
    <A_R_Delinquency_Notice_Detail_Join_S2>
    <DocVoucherInvoiceE_ID1>1897265</DocVoucherInvoiceE_ID1>
    <DateInvoiceJ_ID3>2007-10-11</DateInvoiceJ_ID3>
    <DateDueJulian_ID5>2007-12-10</DateDueJulian_ID5>
    <NameRemark_ID7></NameRemark_ID7>
    <AmountOpen_ID11></AmountOpen_ID11>
    <AddressNumber_ID17></AddressNumber_ID17>
    <UniqueKeyIDInternal_ID19></UniqueKeyIDInternal_ID19>
    <KAV_CustomerPONumber_ID23></KAV_CustomerPONumber_ID23>
    </A_R_Delinquency_Notice_Detail_Join_S2>
    <A_R_Delinquency_Notice_Detail_Join_S2>
    <DocVoucherInvoiceE_ID1>1897265</DocVoucherInvoiceE_ID1>
    <DateInvoiceJ_ID3>2007-10-11</DateInvoiceJ_ID3>
    <DateDueJulian_ID5>2007-11-10</DateDueJulian_ID5>
    <NameRemark_ID7></NameRemark_ID7>
    <AmountOpen_ID11></AmountOpen_ID11>
    <AddressNumber_ID17></AddressNumber_ID17>
    <UniqueKeyIDInternal_ID19></UniqueKeyIDInternal_ID19>
    <KAV_CustomerPONumber_ID23></KAV_CustomerPONumber_ID23>
    </A_R_Delinquency_Notice_Detail_Join_S2>
    RTF:
    <?for-each:Header_Section_S3?>
    <?if:DateDueJulian_ID5 <= AsOfDate_ID47?>
    <?DocVoucherInvoiceE_ID1?>
    <?DateDueJulian_ID5?>
    <?AsOfDate_ID47?>
    <?end if?>
    <?end for-each?>

    Found the solution! Use Date_Diff.
    <?if:xdoxslt:date_diff('d',DateDueJulian_ID5,AsOfDate_ID47,$_XDOLOCALE,$_XDOTIMEZONE)>=0?>

  • XPath Expression Builder Performance after Oracle FMW PS4 Upgrade

    Hi,
    Is there anyone out there on OFMW PS4 and facing performance issues with the BPEL Assign 'XPath Expression Builder'. We have a scenario where the BPEL process has to reference many schemas (arnd. 50+) from referenced Partner Link WSDLs and its own composite. The Expression Builder seems to be very very slow (takes minutes to load) as compared PS2 (only seconds).
    Are we alone on this one / anyone has any experience/fix/workaround?
    BTW,
    We've unchecked the "Validate" check box from SOA Preferences, still no luck.
    Regards,
    Srinath.

    Hi,
    Is there anyone out there on OFMW PS4 and facing performance issues with the BPEL Assign 'XPath Expression Builder'. We have a scenario where the BPEL process has to reference many schemas (arnd. 50+) from referenced Partner Link WSDLs and its own composite. The Expression Builder seems to be very very slow (takes minutes to load) as compared PS2 (only seconds).
    Are we alone on this one / anyone has any experience/fix/workaround?
    BTW,
    We've unchecked the "Validate" check box from SOA Preferences, still no luck.
    Regards,
    Srinath.

  • Expression Builder In Oracle Rule Authoe

    Hi,
    I am using expression builder for making this kind of expression:
    x = y* (new Double(.02))
    where x and y are Double.
    after inserting the variables and operator, validation always fails showing the following message:
    Cannot perform operation. 'RUL-01726: Data type operator for *, at position 10: java.lang.Double * java.lang.Double '
    Please tell me where i am going wrong. It's very urgent.

    Thanks for the reply Phil.
    I think that when I am updating datamodel, it is updating every thing in data model i.e. variables, constraints, functions, facts everything.
    Do you have knowledge of any method in the API which updates only variables??
    Also, i followed a different methodolgy be using RuleSession. have a look at code snippet:
    String rsrl ;
    * Double testValue = 6000.0;*
    * Double discount = new Double(0);*
    * try {*
    * rsrl = dict.ruleSetRL( ruleSetName );*
    * String dmrl = dict.dataModelRL();*
    * RuleSession session = new RuleSession();*
    * session.executeRuleset( dmrl );*
    * session.executeRuleset( rsrl );*
    * discount = (Double)session.callFunctionWithArgument("DM.calculateDiscount",testValue);*
    * System.out.println(" Discount "+discount);*
    * } catch (Exception e) {*
    * e.printStackTrace();*
    Here instead of updating dataModel i am executing ruleSet using session and callingFunction to calculate discount.
    Now if disocunt is populated independent of any other vairable (e.g. discount = 10.0d instead of discount = 10.0*salesValue)
    then it should work. But if discount is dependent on some variable (which has to be global Variable) then it would not populate it.
    This is what i have thought.
    But the above code snippets always give following exception :
    oracle.rules.rl.exceptions.InvocationException: wrong argument type in function or method invocation
    even when function takes arguments in my dictionary.
    Your help is much awaited!! Thanks in advance.

Maybe you are looking for

  • "Protect" printer - ensure only I can print to it?

    Hello! I have an HP Deskjet 5150, attached to my PowerMac G4, which is shared so that I can print from my Powerbook from anywhere in/near my room - so that I'm not tethered to my USB cables. I'm in a dorm - and the LAN/Wireless LAN seems to cover sev

  • IChat Video Chats Not Working

    Hi, I always video chated on my iChat until about a month ago. My friend tried to video chat me and everytime she tried it would say there was a communication error and that she failed to respond. Then I tried sending the invite to her and the same t

  • After I use the Develop module in LR4 I edit in PS-CS4, now the develop changes do not show in CS4.

    After I use the Develop module in LR4 I edit in PS-CS4, now the develop module changes do not show in CS4.

  • Pictures NTSC to PAL

    I have downscaled and sharpen my pictures in Photoshop. They got the resolution 720x480 which is NTSC. Then I made a video in Premiere Pro CS5. I forget that the other videos to the DVD is PAL. Now I have 2 PAL 4:3 videos, 1 PAL 16:9 video and this 4

  • Dv7 microphone stopped working

    The microphone on my HP Pavilion dv7-6b56nr Entertainment Notebook PC has suddenly stopped working.  It's not working in any application, not even the "record" program installed here, nor Skype or Google chat or any other. I have tried uninstalling a