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)

Similar Messages

  • How to use aggregate function with Date

    Hi All,
    I have a group of date from that is it possible to Max and Min of date.
    I have tried like this but its errored out <?MIN (current-group()/CREATION_DATE)?>.
    I have also tried like this but it doesnt works
    <?xdoxslt:minimum(CREATION_DATE)?>
    Is it possible to use aggregate function with date values.
    Thanks & Regards
    Srikkanth

    Hi KAVI PRIYA,
    if date is not in cannonical format, how can we change it in BI publisher, then how to calcualte minimum and as well as maximum.
    please advise me,
    Thanks,
    Sri

  • How to use MAX() function with date field

    Hi Frzz,
    I have created a Graphical calculation view in which i have multiple records for each employee with different dates. But my requirement is to take the records which have maximum date.
    I have converted the date into Integer and applied the MAX() function. But still am getting multiple records.
    Is there is any other way we can achieve this requirement in Graphical Calculation view??  Your suggestion will really help me.
    Thank  you.
    Krishna.

    Hmm... what have you tried out so far?
    Look, I took the effort and created a little example, just for you
    Assume we have a table that contains the logon dates of users.
    Every line contains the logon date and some info on the user.
    Very much like a not-normalized log file could look like.
    Now, the output we want is: one line per user with the most current logon time.
    Not too difficult:
    1. Have a aggregation node that gives you the distinct user details - one line for every user:
    2. Have another aggregation node that gives you the last (MAX) logon date per user:
    Finally you do a 1:1 join on the USER_ID and map the result to the output.
    Easy as pie
    - Lars

  • How to use INVOKE function with INT parameter types

    Can you tell me how to use invoke function with int parameter type ?

    Pass the int as an Integer.

  • How to use analytic function with aggregate function

    hello
    can we use analytic function and aggrgate function in same qurey? i tried to find any example on Net but not get any example how both of these function works together. Any link or example plz share with me
    Edited by: Oracle Studnet on Nov 15, 2009 10:29 PM

    select
    t1.region_name,
    t2.division_name,
    t3.month,
    t3.amount mthly_sales,
    max(t3.amount) over (partition by t1.region_name, t2.division_name)
    max_mthly_sales
    from
    region t1,
    division t2,
    sales t3
    where
    t1.region_id=t3.region_id
    and
    t2.division_id=t3.division_id
    and
    t3.year=2004
    Source:http://www.orafusion.com/art_anlytc.htm
    Here max (aggregate) and over partition by (analytic) function is in same query. So it means we can use aggregate and analytic function in same query and more than one analytic function in same query also.
    Hth
    Girish Sharma

  • Trunc function with date

    when i use in my proceadure where trunc(timesent_acct) between '30-AUG-2006' and '27-SEP-2006' it returns 410 rows
    but
    when i use where timesent_acct between '30-AUG-2006' and '27-SEP-2006' it returns me 400 rows
    what actually happened out there my data stored in timestamp like this '9/27/2006 10:24:18 AM'
    what trunc actually do with dates
    thanks

    Hello,
    Trunc() without parameter retire the hour part of a date.
    SQL> alter session set nls_date_format='DD/MM/YYYY HH24:MI:SS'
      2  /
    Session modifiée.
    SQL> select sysdate, trunc(sysdate) from dual
      2  /
    SYSDATE             TRUNC(SYSDATE)
    07/11/2006 14:51:04 07/11/2006 00:00:00
    SQL> Francois

  • How to execute a function with date parameter as an input?

    HI
    I have a function named fun1(v_fun in date), with date as an input parameter and it returns a number. I have created the function successfully. But i couldnt execute this function in sqlplus. How to pass the dates? Can any one help me in this regard.

    Hi,
    V11081985 wrote:
    HI
    I have a function named fun1(v_fun in date), with date as an input parameter and it returns a number. I have created the function successfully. But i couldnt execute this function in sqlplus. It's hard for me to say what you're doing wrong when I don't know what you're doing. Post a complete test script that people can run to re-create the problem and test their ideas. Include a function definition, CREATE TABLE and INSERT statements for any of your own tables (if necessary), and the results you want to get from that data, as well as your query.
    How to pass the dates? Can any one help me in this regard.You can call the function like this:
    SELECT  fun1 (hiredate)  AS fun1_results
    FROM    scott.emp
    ;

  • How to use trignometric functions with MIDP1.0

    HI ALL!
    We designed midlet to run on a mobile phone using MIDP1.0. We have some additional trignometrical classes to integerate with the midlet. But we got astonished when we didn't find any trignometrical function in MIDP1.0 & CLDC1.0. It is now is a great panic for us.
    It is very unbelievable that Sun Microsystem doesn't provide such classes with J2ME!!
    Is there any way to define or get a free-ware trignometrical classes to use?
    We hope reply from this Forum soon!

    Mmmm....,J2ME currently doesn't support doubles,floats and if you want to use trigonometric functions then you will use cos, sin, tan, ctan,atan,acos,asin and this means doubles and floats....

  • How to use Substring function with Case statement.

    Hello Everyone,
    I have one requirement where I have to use substring function on the field for report criteria.
    E.G.
    I have Branch Name Field where I have all branch names information, Now some of the branch names are too big with some extension after the name .
    now i want to substing it but the character length varies for each branch.
    so is there any way where we can use case statement where we can define that if branch name character are exceeding some value then substing it with this length.

    Try something like this:
    CASE WHEN LENGTH(tablename.Branch_Name) > n THEN SUBSTRING(...) ELSE tablename.Branch_Name END
    where n is the number of characters you want to start the break.

  • Oracle Data Mining - How to use PREDICTION function with a regression model

    I've been searching this site for Data Mining Q&A specifically related to prediction function and I wasn't able to find something useful on this topic. So I hope that posting it as a new thread will get useful answers for a beginner in oracle data mining.
    So here is my issue with prediction function:
    Given a table with 17 weeks of sales for a given product, I would like to do a forecast to predict the sales for the week 18th.
    For that let's start preparing the necessary objects and data:
    CREATE TABLE T_SALES
    PURCHASE_WEEK DATE,
    WEEK NUMBER,
    SALES NUMBER
    SET DEFINE OFF;
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('11/27/2010 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 1, 55488);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('12/04/2010 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 2, 78336);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('12/11/2010 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 3, 77248);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('12/18/2010 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 4, 106624);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('12/25/2010 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 5, 104448);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('01/01/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 6, 90304);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('01/08/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 7, 44608);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('01/15/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 8, 95744);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('01/22/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 9, 129472);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('01/29/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 10, 110976);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('02/05/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 11, 139264);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('02/12/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 12, 87040);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('02/19/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 13, 47872);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('02/26/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 14, 120768);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('03/05/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 15, 98463.65);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('03/12/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 16, 67455.84);
    Insert into T_SALES
    (PURCHASE_WEEK, WEEK, SALES)
    Values
    (TO_DATE('3/19/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS'), 17, 100095.66);
    COMMIT;
    There are a lot of linear regression models and approaches for sales forecast out on the market, however I will focus on what oracle 11g offers i.e. package SYS.DBMS_DATA_MINING to create a model using regression as mining function and then, once the model is created, to apply prediction function on the model.
    Therefore I'll have to go through few steps:
    i) normalization of data
    CREATE OR REPLACE VIEW t_sales_norm AS
    SELECT week,
    sales,
    (sales - 91423.95)/27238.3693126778 sales_norm
    FROM t_sales;
    whereas the numerical values are the mean and the standard deviation:
    select avg(sales) from t_sales;
    91423.95
    select stddev(sales) from t_sales;
    27238.3693126778
    ii) auto-correlation. For the sake of simplicity, I will safely assume that there is no auto-correlation (no repetitive pattern in sales among the weeks). Therefore to define the lag data I will consider the whole set:
    CREATE OR REPLACE VIEW t_sales_lag AS
    SELECT a.*
    FROM (SELECT week,
    sales,
    LAG(sales_norm, 1) OVER (ORDER BY week) L1,
    LAG(sales_norm, 2) OVER (ORDER BY week) L2,
    LAG(sales_norm, 3) OVER (ORDER BY week) L3,
    LAG(sales_norm, 4) OVER (ORDER BY week) L4,
    LAG(sales_norm, 5) OVER (ORDER BY week) L5,
    LAG(sales_norm, 6) OVER (ORDER BY week) L6,
    LAG(sales_norm, 7) OVER (ORDER BY week) L7,
    LAG(sales_norm, 8) OVER (ORDER BY week) L8,
    LAG(sales_norm, 9) OVER (ORDER BY week) L9,
    LAG(sales_norm, 10) OVER (ORDER BY week) L10,
    LAG(sales_norm, 11) OVER (ORDER BY week) L11,
    LAG(sales_norm, 12) OVER (ORDER BY week) L12,
    LAG(sales_norm, 13) OVER (ORDER BY week) L13,
    LAG(sales_norm, 14) OVER (ORDER BY week) L14,
    LAG(sales_norm, 15) OVER (ORDER BY week) L15,
    LAG(sales_norm, 16) OVER (ORDER BY week) L16,
    LAG(sales_norm, 17) OVER (ORDER BY week) L17
    FROM t_sales_norm) a;
    iii) choosing the training data. Again, I will choose the whole set of 17 weeks, as for this discussion in not relevant how big should be the set of training data.
    CREATE OR REPLACE VIEW t_sales_train AS
    SELECT week, sales,
    L1, L2, L3, L4, L5, L6, L7, L8, L9, L10,
    L11, L12, L13, L14, L15, L16, L17
    FROM t_sales_lag a
    WHERE week >= 1 AND week <= 17;
    iv) build the model
    -- exec SYS.DBMS_DATA_MINING.DROP_MODEL('t_SVM');
    BEGIN
    sys.DBMS_DATA_MINING.CREATE_MODEL( model_name => 't_SVM',
    mining_function => dbms_data_mining.regression,
    data_table_name => 't_sales_train',
    case_id_column_name => 'week',
    target_column_name => 'sales');
    END;
    v) finally, where I am confused is applying the prediction function against this model and making sense of the results.
    On a search on Google I found 2 ways of applying this function to my case.
    One way is the following:
    SELECT week, sales,
    PREDICTION(t_SVM USING
    LAG(sales,1) OVER (ORDER BY week) as l1,
    LAG(sales,2) OVER (ORDER BY week) as l2,
    LAG(sales,3) OVER (ORDER BY week) as l3,
    LAG(sales,4) OVER (ORDER BY week) as l4,
    LAG(sales,5) OVER (ORDER BY week) as l5,
    LAG(sales,6) OVER (ORDER BY week) as l6,
    LAG(sales,7) OVER (ORDER BY week) as l7,
    LAG(sales,8) OVER (ORDER BY week) as l8,
    LAG(sales,9) OVER (ORDER BY week) as l9,
    LAG(sales,10) OVER (ORDER BY week) as l10,
    LAG(sales,11) OVER (ORDER BY week) as l11,
    LAG(sales,12) OVER (ORDER BY week) as l12,
    LAG(sales,13) OVER (ORDER BY week) as l13,
    LAG(sales,14) OVER (ORDER BY week) as l14,
    LAG(sales,15) OVER (ORDER BY week) as l15,
    LAG(sales,16) OVER (ORDER BY week) as l16,
    LAG(sales,17) OVER (ORDER BY week) as l17
    ) pred
    FROM t_sales a;
    WEEK, SALES, PREDICTION
    1, 55488, 68861.084076412
    2, 78336, 104816.995823913
    3, 77248, 104816.995823913
    4, 106624, 104816.995823913
    As you can see for the first row there is a value of 68861.084 and for the rest of 16 values is always one and the same 104816.995.
    Question: where is my week 18 prediction ? or maybe I should say which one is it ?
    Another way of using prediction even more confusing is against the lag table:
    SELECT week, sales,
    PREDICTION(t_svm USING a.*) pred
    FROM t_sales_lag a;
    WEEK, SALES, PREDICTION
    1, 55488, 68861.084076412
    2, 78336, 75512.3642096908
    3, 77248, 85711.5003385927
    4, 106624, 98160.5009687461
    Each row out of 17, its own 'prediction' result.
    Same question: which one is my week 18th prediction ?
    Thank you very much for all help that you can provide on this matter.
    It is as always highly appreciated.
    Serge F.

    Kindly let me know how to give input to predict the values for example script to create model is as follows
    drop table data_4svm
    drop table svm_settings
    begin
    dbms_data_mining.drop_model('MODEL_SVMR1');
    CREATE TABLE data_4svm (
    id NUMBER,
    a NUMBER,
    b NUMBER
    INSERT INTO data_4svm VALUES (1,0,0);
    INSERT INTO data_4svm VALUES (2,1,1);
    INSERT INTO data_4svm VALUES (3,2,4);
    INSERT INTO data_4svm VALUES (4,3,9);
    commit;
    --setting table
    CREATE TABLE svm_settings
    setting_name VARCHAR2(30),
    setting_value VARCHAR2(30)
    --settings
    BEGIN
    INSERT INTO svm_settings (setting_name, setting_value) VALUES
    (dbms_data_mining.algo_name, dbms_data_mining.algo_support_vector_machines);
    INSERT INTO svm_settings (setting_name, setting_value) VALUES
    (dbms_data_mining.svms_kernel_function, dbms_data_mining.svms_linear);
    INSERT INTO svm_settings (setting_name, setting_value) VALUES
    (dbms_data_mining.svms_active_learning, dbms_data_mining.svms_al_enable);
    COMMIT;
    END;
    --create model
    BEGIN
    DBMS_DATA_MINING.CREATE_MODEL(
    model_name => 'Model_SVMR1',
    mining_function => dbms_data_mining.regression,
    data_table_name => 'data_4svm',
    case_id_column_name => 'ID',
    target_column_name => 'B',
    settings_table_name => 'svm_settings');
    END;
    --to show the out put
    select class, attribute_name, attribute_value, coefficient
    from table(dbms_data_mining.get_model_details_svm('MODEL_SVMR1')) a, table(a.attribute_set) b
    order by abs(coefficient) desc
    -- to get predicted values (Q1)
    SELECT PREDICTION(MODEL_SVMR1 USING *
    ) pred
    FROM data_4svm a;
    Here i am not sure how to predict B values . Please suggest the proper usage . Moreover In GUI (.NET windows form ) how user can give input and system can respond using the Q1

  • How to use LIKE function with a parameter in Oracle REPORT builder??

    how could i use parameter inside a LIKE function in Oracle reports builder?
    it works in SQL plus, but not in report builder!!
    Example:
    select code,desc from item_master where desc
    like '%&give_desc%'; ---works in SQL
    like '%:give_desc%' ---doesn't work in report builder!!

    Hi Renil,
    You will need to use the wildcard character (%) and the concatenation character (||) to join to your user parameter.
    i.e. like '%'||:give_desc||'%'
    Regards,
    John

  • How to use aggregate function with Toplink

    Hi
    My question is how can I get the following select when using Toplink-EJB.3:
    SELECT MAX(fieldname) FROM tablename;
    Thanasi

    Hi KAVI PRIYA,
    if date is not in cannonical format, how can we change it in BI publisher, then how to calcualte minimum and as well as maximum.
    please advise me,
    Thanks,
    Sri

  • [WebIntelligence Reporting] How to use count function with condition !?

    Post Author: xuanthuyit
    CA Forum: WebIntelligence Reporting
    Hi everyone,
    I want to make a report like this  with WebIntelligence reporting.
    I want to show the number of Outlet of each chanel (Horeca, Grocery, Convenience) at the end of report !
    But I don't know how to do that with WebIntelligence Reporting.
    Please help asap. . .
    Thank you verry much,

    Post Author: jsanzone
    CA Forum: WebIntelligence Reporting
    xuanthuyit:
    Apparently =count() &#91;and use of a where&#93; was permissible in previous versions of BusObjects, however, things in XI are different (as other users tell me, being XI is my first experience w/ BusObj...), so anyhow, here is the solution to your question.
    You will have have to create two variables for each condition you have.  One variable will be the "helper" and the other variable will be the "worker".  For instance, create a variable called channel_x and the formula:  =if(channel="haney";<metric>;0)  (where "haney" is the name of your organization and <metric> is the metric you are using to count or sum things in your report).  Once channel_x is saved create another variable called channel_x_count and the formula:  =sum(&#91;channel_x&#93;).  Once channel_x_count is saved, then on your report towards the bottom you can use the Template bar to drag in a new table (perhaps you want to use the Horizontal Table type), and then you can drag channel_x_count into your new table.  You will have to repeat the creations of more channel_x type variables (maybe call it channel_y and channel_y_count) or something more descriptive, but in any case substitute the "haney" constant for the next store you want to track, etc, etc.

  • How to use matlab function with labview?

    Hello,
    I just want to use some matlab functions like floor(),ones()... in my labview code, who can tell me how to do it?
     I want to only install MCR in my PC, so MATLAB script node can not work because it need matlab installed. 
    Thanks
    Solved!
    Go to Solution.

    floor() exists on the standard labview pallet already and the ones() function would be fairly simple to reproduce. If you only need a few basic functions repost asking for direction on recreating those specific methods. However, you're right - there is not a direct way to use compiled matlab code in labview without full matlab and the math script nodes. If you're really desparate to reuse some some exisiting IP there are C++ alternatives that implement many of the same methods and syntax as matlab (http://arma.sourceforge.net/faq.html). I'm fairly sure there are other tools that attempt to translate matlab code into pure c functions, both of which can be called via a DLL from within labview: https://decibel.ni.com/content/docs/DOC-9076
    Alternatively, here is an all NI linear algebra solution: http://sine.ni.com/nips/cds/view/p/lang/en/nid/210525

  • How to Use ADF Region With Data Bound Controls in JDeveloper 10g

    I want to use Data Bound ADF Components in Region. Is there any way to acheive this. I want to get Employee Information from a View Object and display it in a region and use this region on different pages.

    I could not understand the dynamic part.
    Actually the problem is that i use Data Controls in Region but when i use the region in other pages it does not display the Data Control.
    Let say i have a data bound outputtext field.
    <af:panelLabelAndMessage label="#{bindings.EmpmasterinfoViewEmployeeid.label}">
    <af:outputText value="#{bindings.EmpmasterinfoViewEmployeeid.inputValue}"/>
    </af:panelLabelAndMessage>
    But this field does not display any thing.
    How i will be able to diplay other data bound controls like table etc.
    Thanks for your reply

Maybe you are looking for

  • Installation Problem Oracle 9.2.0.4 on Red Hat Linux 5

    I have installed Red Hat Enterprise Linux 5. I want to install Oracle 9i (9.2.0.4) Server. I have created oracle user and set oracle home directory in the .bash_profile.After that i run runinstaller file but the message comes as below.. 'The user is

  • Possible to replace 30gig HD with a 60gig HD?

    If I buy a replacement 60gig hard drive on ebay or whatnot, would it be possible to replace it with the hard drive in my 30 gig ipod? Would this be compatible?

  • Turn off Debugging within a script

    Hi everyone, I have a script which does a big batch daily job - however if debugging is active on the server it manages to bring the server down as it just takes too long. However as there is a big team of developers here from time to time people nee

  • How to handle response.sendRedirect(url) in a portlet w/ webflow?

    I am using a webflow to navigate within a portlet. There are three jsp pages or nodes in the portlet. One of the jsp pages has the following logic: if (A) { response.sendRedirect(url1)} else if(B) { response.sendRedirect(url2)} else{display rest of t

  • Mac Mini as mail server

    Okay, Im a mac noob.  But as the IT Guy for a small company I have been tasked with moving our email from a hosted email provider to inhouse. We have about 85 email accounts. My question is Looking at the new mac mini with lion it seems to have enoug