Why oracle "to_date" accepts Date-parameters

I tested out function "to_date" as you see below and I see that Oracle allows me to give to that function parameter with textual data type and also allows to parameter's datatype to be Date.
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
SQL>
SQL> select to_date(sysdate) as s from dual;--21.10.2010
S
21.10.2010
SQL> select to_date(sysdate, 'DD.MM.YYYY') as s from dual;--21.10.2010
S
21.10.2010
SQL> select to_date('21.10.2010', 'DD.MM.YYYY') as s from dual;--21.10.2010
S
21.10.2010
SQL> select to_date(to_date('21.10.2010', 'DD.MM.YYYY')) as s from dual;--21.10.2010
S
21.10.2010
SQL> I entered into Search engine "http://www.lycos.com/" phrase "oracle to_date function" and it gave me link to documentation of that function:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions183.htm
and the documentation says:
>
Purpose
TO_DATE converts char of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 datatype to a value of DATE datatype.
>
My question is: why the function accepts Date data types? what occures behind curtains when Date is passed in? Or what explanation there is, that documentation seems to lie?
Also, have you too noticed that the forum has been oftenly down near past days?

Any function that accepts a VARCHAR2 can be passed a DATE. Oracle will simply implicitly cast the DATE to a VARCHAR2 (using the session's NLS_DATE_FORMAT). The same way that it would implicitly cast a NUMBER to a VARCHAR2.
Of course, if the implicit conversion of the date to a string doesn't match the explicit format mask passed to TO_DATE, you'll have a problem. If your session's NLS_DATE_FORMAT was 'MM.DD.YYYY', for example, the TO_DATE would fail because Oracle would implicitly cast the date to a string in the format MM.DD.YYYY and then try to convert that to a date using the format mast DD.MM.YYYY.
Justin

Similar Messages

  • Oracle 8i, Why would it accept date of 00-JUN-01 without an error

    I have an application (On Track for Training) written in power builder and using sqlnet. When the user signs on to the Oracle 8i Database, using ODBC driver 8.1.5.5, some of my users send an invalid date into a controlkey field. The format has a 00 day in the date field (00-JUN-01). We get no errors when the date gets stored - but it screws up my application for anyone else trying to sign into it. When the program sees that invalid date, it bombs out. Any record those users save while using the system also stores this invalid date format with no errors from Oracle. They only get an error when they try to view the record after it has been saved.
    Any ideas as to what could be looking like a valid date to Oracle but really is a 00 day? I just can't understand why it's not erroring out and stopping these people from creating havoc in the system. The software devlopers blame the ODBC driver - but no one seems to be able to tell me what about the ODBC driver could be wrong. I'm thinking it's a Windows/System .dll file that is getting overwritten any time these users install a new piece of software on their system. I just have no idea which ones to look at.
    Any help would be appreciated.

    Wierd! Regardless of what the ODBC driver does, the database should reject an invalid date. The fact that Oracle appears to be storing invalid data would seem to imply that the ODBC driver isn't at fault...
    I would tend to discount the possibility of an overwritten DLL causing this. Nothing that the client does should ever cause a database to store an invalid date. Most of the time, when there's a DLL conflict, the failures are a lot less subtle.
    I'd strongly suggest that you contact Oracle support about this. At a minimum, there's apparently a database bug. Probably, there's some sort of interaction between the ODBC driver, OCI (the API the ODBC driver uses to communicate with the database), and the database that allows the root bug to be manifested. There may even be bugs in the ODBC or OCI layers. It certainly sounds like this is a problem that someone will have to spend a few hours with some debugging tools to figure out what's going on.
    One other route you might try is updating all your components with the latest patchsets-- perhaps the bugs have already been identified & fixed. If you go to <ftp://oracle-ftp.oracle.com/server/patchsets/wgt_tech/server/windowsNT/81patchsets/>, you can grab the latest 8.1.5 and 8.1.6 patchsets (8.1.5.1.1 & 8.1.6.3.4). Update both your client & server with the appropriate patchset. Also, you can grab the 8.1.5.7 ODBC driver off of OTN and install that. If the problem goes away, life is good. If it doesn't, I think you're going to need support's help.
    Justin
    null

  • Date Parameters in Data Templates..

    Mornin all..
    How are you using date parameters in your Data templates..?
    I'm trying to run a Conc Program that has a date parameter. in ORACLE Con Program the value set is setup to retrieve the format dd-MON-yyyy.
    I also have this format specified in the Data Template..
    <parameter name="p_paydate_from" dataType="character" />
    <parameter name="p_paydate_to" dataType="character" /> ..and then again in the SELECT statement..
    <![CDATA[
    SELECT DISTINCT.......
    TO_CHAR(ip.creation_date, 'dd-MON-yyyy') Paid_Date, sfc.faculty_code Faculty, etc..
    FROM
    WHERE
    AND TRUNC(ip.creation_date) BETWEEN NVL(:p_paydate_from, '01-JAN-1999') AND NVL(:p_paydate_to, '31-DEC-2299')...
    ]]>..yet when I run the report it just ignores the data parameter and returns all records..
    I know that if that this was done in ORACLE Reports I'd have to place this in AfterPFormTrigger..
    IF :p_paydate_from is not null then
    :lp_paydate_from := 'and ip.accounting_date >= to_date(:p_paydate_from, ''YYYY/MM/DD HH24:MI:SS'')' ;
      ELSE      :lp_paydate_from := '';
      END IF;
        IF :p_paydate_to is not null then
              :lp_paydate_to := 'and ip.accounting_date <= to_date(:p_paydate_to, ''YYYY/MM/DD HH24:MI:SS'')' ;
      ELSE       :lp_paydate_to := '';
      END IF; Question is - do I have to create a trigger and put it into my data template or am I working the date parameter wrongly..? How do you use date parameters in your Data templates..?
    Many thanks for Looking..
    Steven
    Edited by: JackyWhite on May 14, 2010 12:20 PM

    Thanks for the comments.
    I am able to return records when using the code in the SELECT statement via TOAD.
    I've tried specifying dates in the parameter section but it was just the same error.
    The error message given when I include these date parameters when in run the Conc Program is..
    [051410_022803764][][STATEMENT] 8: p_paydate_from:2010/01/01 00:00:00
    [051410_022803764][][STATEMENT] 9: p_paydate_to:2010/01/21 00:00:00
    --SQLException
    java.sql.SQLException: ORA-01861: literal does not match format string
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)I know what the problem is, I just done know how to fix it. I'll try to explain. In ORACLE reports
    In the Conc Program (running the report) The date can be entered in the format 'DD-MON-YYYY'
    In the Report Oracle sends this date to the report in the format 'YYYY/MM/DD HH24:MI:SS'. To accept this date in the report the easiest method is to.....
    1. Create the date parameter as a varchar(20) instead of a date type
    2. In the After Parameter Trigger convert the date either into a local variable or into a lexical variable (used in the SQL query) by using the code
             to_date(:p_date_parameter_name, '''YYYY/MM/DD HH24:MI:SS'')
         srw.message(10, 'P Date from ' ||:p_date_from);
          if :p_paydate_from is not null then
              :Lp_paydate_from := 'and trunc(...............) >= to_date(:p_paydate_from,''YYYY/MM/DD HH24:MI:SS'')';
           :disp_date_from := to_char(to_date(:p_paydate_from,'YYYY/MM/DD HH24:MI:SS'),'DD-MON-YYYY');
              srw.message(10, 'LP Date from ' ||:lp_paydate_from);
          end if; etc etc etc..      end if;I know that if I can convert it somewhere somehow using that 'to_date(:p_paydate_from,...' thing then I reckon it should work..
    I'm currently trying to figure out (a tad rusty at PLSQL now) how can I create an afterpform trigger to be called in the data template that does the above (basically just to convert the date format)..
    PLease tell me there is an easier way!
    Thanks!
    Steven

  • Date Parameters

    Hi,
    Please see my query below,
    I'm having a bit of trouble with my date parameters.
    If $P{from_date} = 01-Jan-2010
    and $P{to_date} = 02-Jan-2010
    Is there a reason why i'm not getting any data for 02-Jan-2010?
    It's probably something simple that i'm missing.
    select
    count(tag_id),
    itl.sku_id,
    itl.client_id,
    itl.reference_id,
    sum(itl.update_qty),
    to_char(trunc(itl.dstamp), 'DD-Mon-YYYY') rec_date,
    to_char(sysdate, 'DD-Mon-YYYY | HH24:MI:SS') as systemdate,
    to_char(trunc(itl.expiry_dstamp), 'DD-Mon-YYYY') exp_date,
    s.ship_shelf_life as sku_shelf_life,
    s.ship_shelf_life + 2 as plus_shelf_life,
    (trunc(itl.expiry_dstamp) - (s.ship_shelf_life + 2)) - trunc(sysdate) as plus_days_left,
    (trunc(itl.expiry_dstamp) - (s.ship_shelf_life + 2)) - trunc(itl.dstamp) as plus_days_left_when_rec,
    (trunc(itl.expiry_dstamp) - trunc(itl.dstamp)) as clear_days
    from inventory_transaction itl, sku s
    where s.sku_id = itl.sku_id
    and ($P{from_date} is null or ($P{from_date} is not null and itl.dstamp >= to_date($P{from_date}, 'DD-Mon-YYYY')))
    and ($P{to_date} is null or ($P{to_date} is not null and itl.dstamp <= to_date($P{to_date}, 'DD-Mon-YYYY')))
    and itl.code = 'Receipt'
    group by itl.sku_id, itl.client_id, to_char(trunc(itl.expiry_dstamp), 'DD-Mon-YYYY'), to_char(trunc(itl.dstamp), 'DD-Mon-YYYY'),
    itl.reference_id, s.ship_shelf_life, s.ship_shelf_life + 2, (trunc(itl.expiry_dstamp) - (s.ship_shelf_life + 2)) - trunc(sysdate),
    (trunc(itl.expiry_dstamp) - (s.ship_shelf_life + 2)) - trunc(itl.dstamp), (trunc(itl.expiry_dstamp) - trunc(itl.dstamp))
    order by itl.client_id, itl.sku_idThanks in advance,
    SM.

    Sam Mardell wrote:
    Is there a reason why i'm not getting any data for 02-Jan-2010?Yes :) Every date has an hours, minutes and seconds component. When you apply the TO_DATE() function on a character string that just contains month, day, and year the time component defaults to midnight (00:00:00). There are multiple methods to get around this:
    < to_date($P{to_date}, 'DD-Mon-YYYY') + 1
    <= to_date($P{to_date} || '23:59:59', 'DD-Mon-YYYY HH24:MI:SS')
    <= to_date($P{to_date}, 'DD-Mon-YYYY') + (60*60*24 - 1)Above are just examples, there are many more ways to achieve this.
    HTH!

  • How to use Count with Date Parameters

    Hello,
    I am having issues using the Count() function in conjunction with date parameters.
    This is a Siebel report and in my report I have 2 date parameters(From Date, To Date). In a nutshell I am basically trying to count Opportunities that has a start date within the given date period. However I don't see a reasonable way to put my date parameters within the Count() function. The reason being is that I need to have a huge chunk of code to convert the dates into a common format that can be compared, and it won't even fit within the code block in my rtf template. I am not even sure how to put multiple conditional statements inside a Count() function since all the examples I have seen are very simple.
    Anyone have a suggestion on how to use Count() with date parameters?
    Thanks.

    Any chance you can get the date formats in the correct format from siebel?
    I don't know Siebel - so I can't help you with that. If you get the correct format it is just
    <?count(row[(FromDate>=date) and  (date<=ToDate))?>
    Otherwise the approach would probably need to use string function to get year/monthd/day from the date
    and store it into a varialbe and compare later the same way
    <?variable@incontext:from; ....?>
    <?variable@incontext:to; ...?>
    <?count(row[($from>=date) and  (date<=$to))?>
    Potentially you can use the date functions such as xdofx:to_date to do the conversion
    [http://download.oracle.com/docs/cd/E12844_01/doc/bip.1013/e12187/T421739T481158.htm]
    But I am not sure if they are available in your siebel implementation.
    Hope that helps

  • How can I reference records outside the two date parameters?

    Hi all,
    I have a query that fetches records based on the two date parameters defined (Startdate and Enddate).
    If the Startdate is 2014-12-01 and the Enddate is 2014-12-12, I want to pull records outside these two date parameters, that is      2014-09-01 and 2014-11-30.
    I want to add up the records from  2014-09-01 and 2014-11-30 and include them in one of the columns in my report.
    I tried using this query:
     SUM(CASE WHEN FilteredIncident.Statuscodename IN ('QUEUED', 'ASSIGNED') AND (EnteredOn >= '2014-09-01' AND EnteredOn<= @StartDate) THEN 1 ELSE 0 END) AS OpenRecords
    Please help with any ideas..thanks

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you probably need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    There is no such crap as a “status_code_name” in RDBMS. It has to be a “<something in particular>_status”; think about how silly that data element name is! Want to keep going and have a “status_code_name_value_id”? LOL! 
    The name “Filtered_Incident” is also wrong. Tables are sets, so unless you have only one element in this set, the table name should be a plural or (better) collective name. But a better question is why  did you split out “Filtered_Incidents” from “Incidents”?
    Would you also split “Male_Personnel” and “Male_Personnel” from “Personnel”? 
    Get a book on data modeling and learn some basics. 
    >> I have a query that fetches records [sic: rows are nor records] based on the two date parameters defined (report_start_date and report_end_date). If the report_start_date is 2014-12-01 and the report_end_date is 2014-12-12, I want to pull records [sic]
    outside these two date parameters, that is 2014-09-01 and 2014-11-30. I want to add up the records [sic] from 2014-09-01 and 2014-11-30 and include them in one of the columns in my report. <<
    Having no DDL and no sample data makes this hard. Does your boss make you program without any documentation, DDL, etc? This spec is vague; you say to do a total, but show a count, etc. 
    One of the many nice things about DATE data types is that the BETWEEN predicate works with them, so you can quite writing 1960's BASIC predicates with primitive logic operators. 
    Here is a guess: 
    SELECT SUM(CASE WHEN incident_date BETWEEN '2014-09-01' 
               AND @report_start_date THEN 1 ELSE 0 END)
           AS open_record_cnt 
      FROM Incidents
     WHERE incident_status IN ('QUEUED', 'ASSIGNED')
        AND incident_date <= @report_end_date; 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Problem with passing date parameters in cursor

    Is there any problem in passing date parameters and like clause as below
    CURSOR eftcursor(start_date DATE, end_date DATE, where_clause varchar2) IS
    select * from r_records
    where created_date between start_date and end_date and description like where_clause;
    and in the open statement
    select to_date('01/06/2010 00:00:00', 'dd/mm/yyyy hh24:mi:ss') into startDate from dual;
    select to_date('01/07/2010 00:00:00', 'dd/mm/yyyy hh24:mi:ss') into endDate from dual;
    str := '%something%aaaaa%';
    open eftcursor(startDate ,endDate , str);
    Do i need to do any kind of conversion in the cursor where clause or when i am passing the parameter in open statement.

    Almora wrote:
    Do i need to do any kind of conversion in the cursor where clause or when i am passing the parameter in open statement.No, your code looks correct -- ou're passing a date to the cursor.
    You might consider whether you really need an explicit cursor though. An implicit cursor is easier to code and performs better.

  • Controling Date Parameters using SRW.DO_SQL in Reports!

    Hello Friends,
    I Need to Control the Date Parameters in Reports.
    (Dev/2000 rel2.1) In SRW.Do_SQL package
    For Example:
    'Insert into x
    select * from Y
    where Y.date between f_date and t_date';
    Here: X,Y are two tables
    f_date and t_date are two different date parameters in
    format (dd-mm-yyyy).
    NOTE: Without these two date parameters, the Query is working
    fine. But I need to Use these Parameters. Could You Please find a
    solution for Me. Thanks in advance.
    Regards
    Manoj (India)
    (Dt:18thNov'99)
    null

    Manoj (guest) wrote:
    : Hello Friends,
    : I Need to Control the Date Parameters in Reports.
    : (Dev/2000 rel2.1) In SRW.Do_SQL package
    : For Example:
    : 'Insert into x
    : select * from Y
    : where Y.date between f_date and t_date';
    : Here: X,Y are two tables
    : f_date and t_date are two different date parameters
    in
    : format (dd-mm-yyyy).
    : NOTE: Without these two date parameters, the Query is working
    : fine. But I need to Use these Parameters. Could You Please
    find a
    : solution for Me. Thanks in advance.
    : Regards
    : Manoj (India)
    : (Dt:18thNov'99)
    Hi Manoj
    your goal is to supply all three as dates (y.date, f_date,
    t_date). if some of them are not date but char, varchar, ...
    then use to_date conversion function with proper format mask.
    hope this helps.
    null

  • Problem with oracle.jbo.domain.Date

    Hi there,
    I've a problem with oracle.jbo.domain.Date,
    I'm doing this code (this part of code is used in my Session Attribute Listener):
    * This method is used to add the session id in the database, whenever user login
    public void attributeAdded(HttpSessionBindingEvent hsbe){
    if(!hsbe.getName().equals("user")){
    return;
    AmLogin am = (AmLogin)Configuration.createRootApplicationModule(
    "com.ahm.pdt001.am.AmLogin",
    "AmLoginLocal");
    try{
    hsbe.getSession().setAttribute("login", new Date(new Timestamp(
    System.currentTimeMillis())));
    am.createLogin(hsbe.getValue().toString(), hsbe.getSession().
    getAttribute("login").toString());
    } catch(Exception e){
    e.printStackTrace();
    System.out.println("Error insert data user: " + hsbe.getValue());
    } finally{
    Configuration.releaseRootApplicationModule(am, true);
    Everything is running well in Jdev 10.1.3 (I'm using ADF Faces technology), and I'm trying to deploy it on OC4J 10.1.2 and it works. But it raised an error when this part of code is runned.
    --------------caused and error------------------------
    hsbe.getSession().setAttribute("login", new Date(new Timestamp(
    System.currentTimeMillis())));
    And this is an error:
    javax.faces.FacesException: #{pdt001.loginAction}: javax.faces.el.EvaluationException: java.lang.NoSuchMethodError: oracle.jbo.domain.Date.<init>(Ljava/sql/Timestamp;)V     at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)     at oracle.adf.view.faces.component.UIXCommand.broadcast(UIXCommand.java:211)     at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)     at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)     at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)     at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)     at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)     at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:332)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)     at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:367)     at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:336)     at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:196)     at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:20)     at com.ahm.filter.AhmFilterSession.doFilter(AhmFilterSession.java:45)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:645)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)     at java.lang.Thread.run(Thread.java:534)Caused by: javax.faces.el.EvaluationException: java.lang.NoSuchMethodError: oracle.jbo.domain.Date.<init>(Ljava/sql/Timestamp;)V     at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:130)     at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)     ... 23 moreCaused by: java.lang.NoSuchMethodError: oracle.jbo.domain.Date.<init>(Ljava/sql/Timestamp;)V     at com.ahm.pdt001.listener.Pdt001AttributeSessionListener.attributeAdded(Pdt001AttributeSessionListener.java:27)     at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.EvermindHttpSession.setAttribute(EvermindHttpSession.java:128)     at com.ahm.pdt001.bean.Pdt001Bean.loginAction(Pdt001Bean.java:61)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)     at java.lang.reflect.Method.invoke(Method.java:324)     at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
    Does anybody have the same problem like this? I've used the same method in my previous project to create oracle.jbo.domain.Date with current time using java.sql.Timestamp, but I don't know why this error happened.
    Thx,
    Andre

    Re: oracle jbo.domain.Date issues in 10.1.3
    Sascha

  • Convert java.sql.Date to oracle.jbo.domain.Date in oaf

    Hi,
    Need to dafault NeedBydate(i get in from query as below) to a messagelovinput and make it read only.
    i am facing some issue in converting from java.sql.Date to oracle.jbo.domain.Date.
    unable to figure out the problem.
    below is the sample code im trying to use.
    PreparedStatement ps=pageContext.createPreparedStatement("select sysdate from dual");
    ResultSet rs=ps.executeQuery();
    if (rs!=null && ps.next()
    java.sql.Date sqlDate= rs.getDate(1);
    oracle.jbo.domain.Date oracleDate = new oracle.jbo.domain.Date(sqlDate.getTime());
    vorow.setAttribute("Datevalue",oracleDate);
    this is my assumption : to set to UI i need date in format dd-Mon-yyyy.(am i correct? as to get that format i tried to use simple date format class but no use)
    when i tried to use simple date format :unpaseable date exception was raised.
    please guide.

    Hi,
    Why are you using this code???
    PreparedStatement ps=pageContext.createPreparedStatement("select sysdate from dual");
    ResultSet rs=ps.executeQuery();
    if (rs!=null && ps.next()
    java.sql.Date sqlDate= rs.getDate(1);
    oracle.jbo.domain.Date oracleDate = new oracle.jbo.domain.Date(sqlDate.getTime());
    you can get sysdate using this and then set it
    oracle.jbo.domain.Date currentDate = am.getOADBTransaction().getCurrentUserDate();
    java.text.SimpleDateFormat displayDateFormat = new java.text.SimpleDateFormat ("yyyy-MM-dd");
    String DateForm = displayDateFormat.format(currentDate.dateValue());
    oracle.jbo.domain.Date dateset = new oracle.jbo.domain.Date(DateForm);
    and then set the attribute
    vorow.setAttribute("Datevalue",dateset);
    Thanks,
    Gaurav

  • Business Components and oracle.jbo.domain.Date

    Hello I have the next problem I have a Busines Component and I have to acess to rows who have Dates and with oracle.jbo.domain.Date I can4t acess to the day, month, year .
    Can anyone Help me how can I do to access this dates?
    Thanks a lot your your help.

    Hi,
    This is the trilogy problem:
    oracle.jbo.domain.Date
    oracle.sql.DATE
    java.util.Date
    The question is how to translate from one object type to another.
    You can use the following:
    oracle.jbo.domain.Date tmpDate = null;
    SimpleDateFormat tmpLocalFormat = new SimpleDateFormat();
    SimpleDateFormat tmpLocalFormat2 = new SimpleDateFormat();
    // Obtenir la date du sommaire
    tmpDate = (oracle.jbo.domain.Date) session.getValue("DateElem");
    // Initialisation des objets de formatage de date
    tmpLocalFormat.applyPattern("yyyy-MM-dd");
    tmpLocalFormat2.applyPattern("dd-MM-yyyy");
    // Conversion du format de date yyyy-MM-dd => dd-MM-yyyy
    tmpWhereClause = new String(tmpLocalFormat2.format(tmpLocalFormat.parse(tmpDate.toString())));
    // Ajouter ` la clause "Where" la contrainte de la date
    tmpWhereClause = "DrqSommaireInitial.DATE_SOMMAIRE = TO_DATE('" + tmpWhereClause + "', 'DD-MM-YYYY')";
    Take a look also to class calendar...
    null

  • Trouble with stored procedure date parameters in 10.2.0.2

    Hello,
    i have I couple of procedures which were running perfectly on 10.2.0.1.
    After the upgrade to 10.2.0.2 i get the error: ORA-01843: not a valid month ORA-06512: at "MASTERDBI.CREATE_OR_UPDATE_VER_INFO", line 65 ORA-06512: at line 1
    This error is fired up, on an simple insert-stmt within the procedure. That means, that the date-parameter itself ist ok.
    If I set the nls_date_format w/ "alter session...", then the procedure is running like before and everthing is fine. But this causes a big change on other programs. So I tried to set the nls_date_format w/in an schema.logon-trigger. But w/out success. The only solution is to set the nls_date_format explicit like in this example:
    begin
    execute immediate 'alter session set nls_date_format = "dd.mm.yyyy"';
    create_or_update_ver_info(
    10552,
    'VC BK Zuordnung',
    'TEST',
    sysdate,
    1);
    end;
    It seems, that oracle converts the date-param into a string a back again into a date. But, the date format expected is the american date format. The date format delivered is the german format. And this causes the fault.
    Any comments...
    Kind regards
    Harald Simon
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]

    Proc:
    PROCEDURE CREATE_OR_UPDATE_VER_INFO
    p_vertrag_id number,
    p_ver_infotyp varchar2,
    p_text varchar2,
    p_zeitstempel date,
    p_benutzer_id number
    ) as
    v_ver_infotyp_id ver_infotypen.ver_infotyp_id%type;
    v_curr_text ver_infos.text%type;
    begin
    -- Ver-Infotyp ermitteln
    begin
    select ver_infotyp_id into v_ver_infotyp_id from ver_infotypen
    where bezeichnung = p_ver_infotyp;
    exception
    when no_data_found then
    raise_application_error(-20005, 'Vertragsinfotyp "' || p_ver_infotyp || '" in Tabelle VER_INFOTYPEN nicht gefunden.');
    end;
    -- Aktuelle Vertragsinfo ermitteln
    begin
    select text into v_curr_text
    from ver_infos
    where gueltig_bis = to_date('31.12.9999', 'dd.mm.yyyy')
    and ver_infotyp_id = v_ver_infotyp_id
    and vertrag_id = p_vertrag_id;
    exception
    when no_data_found then
    null;
    end;
    -- Wenn der vorhandene Vertragsinfotyp der gleiche ist, dann
    -- sofort wieder raus
    if nvl(v_curr_text, '') = nvl(p_text, '') then
    return;
    end if;
    -- Aktuelle VerInfo löschen
    if not v_curr_text is null then
    update ver_infos
    set gueltig_bis = p_zeitstempel
    where gueltig_bis = to_date('31.12.9999', 'dd.mm.yyyy')
    and ver_infotyp_id = v_ver_infotyp_id
    and vertrag_id = p_vertrag_id;
    end if;
    if p_text is null then
    return;
    end if;
    -- Neue Vertragsinfo einfügen, falls es etwas zum Einfügen gibt
    if not p_text is null then
    insert into ver_infos
    vertrag_id,
    ver_infotyp_id,
    gueltig_von,
    text,
    erstellt_am,
    erstellt_durch
    ) values (
    p_vertrag_id,
    v_ver_infotyp_id,
    p_zeitstempel,
    p_text,
    p_zeitstempel,
    p_benutzer_id
    end if;
    end;
    Test:
    begin
    create_or_update_ver_info(
    10552,
    'VC BK Zuordnung',
    'TEST',
    sysdate,
    1);
    end;
    Result:
    ORA-01843: not a valid month ORA-06512: at "MASTERDBI.CREATE_OR_UPDATE_VER_INFO", line 65 ORA-06512: at line 2
    Test2:
    begin
    execute immediate 'alter session set nls_date_format = "dd.mm.yyyy"';
    create_or_update_ver_info(
    10552,
    'VC BK Zuordnung',
    'TEST',
    sysdate,
    1);
    end;
    Result:
    Statement processed in 0,00 sec
    It is nice, is`nt it?
    Harald
    Message was edited by:
    HSimon

  • Why oracle text index column taking long  time

    why oracle text index column is taking long time to return result.I created text index on a column if I run the query on a single table result is very fast.If I join table with other table (10 records only )
    it is taking long time but in explain plan it is searching by index only.
    I created this index for searching a varchar2 column,the data is comma seperated values like ( UK,US,IT,BR) and the table having records 20 lakhs.Normally if I query with like operater
    ( like '%US%' ) it is taking full table scan because I am using '%' both sides. Please help me on this regard how to search the data with less time. Here is may sample code and explain plan.
    SQL*Plus: Release 9.2.0.1.0 - Production on Wed Jan 28 16:54:22 2009
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    SQL&gt; set timing on
    SQL&gt; set linesize 180
    SQL&gt; explain plan for SELECT T.esongid FROM (SELECT A.ESONGID FROM wcmedeco.EDECO_ESONGS_TERR_CTRY 
    A WHERE CONTAINS(A.TERR_CTRY_NAMES,'US')&gt;0  
      2  GROUP BY A.ESONGID)K,T
      3  WHERE  K.ESONGID=T.ESONGID;
    Explained.
    Elapsed: 00:00:00.01
    SQL&gt; select *from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id  | Operation                      |  Name                   | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT               |                         |     1 |    26 |     4 |
    |   1 |  NESTED LOOPS                  |                         |     1 |    26 |     4 |
    |   2 |   VIEW                         |                         |     1 |    13 |     4 |
    |   3 |    SORT GROUP BY               |                         |     1 |    89 |     4 |
    |   4 |     TABLE ACCESS BY INDEX ROWID| EDECO_ESONGS_TERR_CTRY  |     1 |    89 |     2 |
    |   5 |      DOMAIN INDEX              | IDX_TERR_CTRY_NAMES     |       |       |     0 |
    |   6 |   INDEX RANGE SCAN             | IDX_ESONGID_T           |     1 |    13 |     1 |
    PLAN_TABLE_OUTPUT
    Note: cpu costing is off, 'PLAN_TABLE' is old version
    14 rows selected.
    Elapsed: 00:00:00.00
    SQL&gt; Regards,
    Rajasekhar

    You have not formatted your code properly so we cannot see the query you're executing. Please put some line breaks in.
    Secondly, how fresh are the statistics on those tables? Are you really returning one record out of twenty million?
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Defaulting Date Parameters

    Post Author: tegage
    CA Forum: Formula
    I have many reports that allow the user to specifiy a starting and ending date range.  I would like the reports to default to all dates.  I can do this by defaulting the start date to "01-01-2000" and the end date to "12-31-2099", but then the calendar tool is useless since there is no TODAY button on the calendar tool and it picks up the default date, i.e., the users will have to do a lot of scrolling through the calendar tool.
    The other way is to make the starting and ending date parameters strings and use values like Today, This Week, This Month,....  and reolve them in the record selection formula.   This would be nice, but then if the user wants a specific date range, they don't have the calendar tool to use.
    Is there a way to take advange of the user-friendliness of string values and still have the calendar tool to use?

    Post Author: tegage
    CA Forum: Formula
    Thanks much for the response. 
    I had done exactly what you described - I had a string parameter for Today, This Week, etc and a set of date parameters - Starting and Ending Date.  But, in order to use the Starting and Ending dates in a formula, I had to provide them a default value - leaving them blank causes the record selection formula to explode.  The issue here is that the calendar tool picks up the default value instead of showing today's date. 
    I did more web surfing and found the answer on the Business Objects web site.  The solution let me do what you suggested AND keep the Starting and Ending date parameters as Date types and defaulted to blank by making them optional parameters.
    From the Business Objects web site (why isn't this stuff in the user's guide?):
    2.  Control over default values.
    3.  Request for an 'ALL' value.
    Both of requirements 2 and 3 are met with the new optional parameter feature of CR 2008.  When a parameter is flagged as 'optional', the report can execute without that value being set.  The trick here is that any formula that attempts to reference an optional parameters that doesn't have a value set will return an error.  So we've introduced the new HasValue() function which allows you to check and see if the parameter has a value. 
    This is really powerful, because now you can reference your parameters indirectly through another formula (or custom function) that checks if the parameter has a value or not.  If it does, then the formula returns the parameter value.  If it doesn't, then it can return whatever default value you wish.  So if you want the default to be the day before, or last Friday, then you can code that logic into your formula that uses HasValue to check if the parameter has a value set or not.
    Optional parameters were also intended to solve the 'All' problem.  Basically, you want a parameter to participate in a record selection formula only if it has a value.  If it doesn't, then you want that filter to be disabled.  By using optional parameters and HasValue() in your record selection (and new saved data section) formulas, you can include conditions in your filter only if the parameters in those conditions have a value.

  • Pass date parameters to dataprocessor in Java

    Hello I have created java class to execute data templates, but I have problem when I pass date parameters as it was from application dataprocessor fails without any error message and does not return any data (except output xml file header). How to pass date parameters correctly?
    import java.sql.*;
    import oracle.apps.xdo.dataengine.DataProcessor;
    import com.sun.java.util.collections.Hashtable;
    class oraConn
    public static void main (String args []) throws SQLException
    System.out.println("Start");
    try {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    java.util.Properties ora_property = new java.util.Properties();
    Connection conn =
    DriverManager.getConnection("jdbc:oracle:thin:user/pass@host:port:sid");
    try {
    DataProcessor dataProcessor = new DataProcessor();
    dataProcessor.setDataTemplate("/home/user/definition.xml");
    Hashtable parameters = new Hashtable();
    parameters.put("c_period_start_date","2009/01/01 00:00:00");
    parameters.put("c_period_end_date","2009/12/31 00:00:00");
    parameters.put("c_employed_before_date","");
    parameters.put("c_org_hierarchy","63");
    dataProcessor.setParameters(parameters);
    dataProcessor.setConnection(conn);
    dataProcessor.setOutput("/home/user/Out.xml");
    dataProcessor.processData();
    } catch (Exception e)
    {System.out.println ("Data procesor Fail.");}
    } catch (SQLException ex) {
    System.out.println ("\n*** SQLException caught ***\n");
    while (ex != null) {
    System.out.println ("SQLState: " + ex.getSQLState ());
    System.out.println ("Message: " + ex.getMessage ());
    System.out.println ("Vendor: " + ex.getErrorCode ());
    ex.printStackTrace();
    ex = ex.getNextException ();
    System.out.println ("");
    }}}}

    Found out solution to my problem. I needed to import date not as string but as Date type.

Maybe you are looking for

  • Rollover problem with IE7

    http://www.mawson.com/street/courses.html The link above is my test page I'm working on. My rollovers are workin fine in IE6 and FireFox. It figures that with the new MS browser stuff stops working. The problem is that the rollovers seem very fussy.

  • Fake desktop (so I can store information in it)?

    Hi All, I'd really like to have a desktop like space (maybe one that I can toggle to somehow) where I can store current projects that I am working on. I find it really a bump in the road to have to look at these in a normal Finder window. At the same

  • MS powerpoint through Java

    Hi, I have a requirement to generate PPT slides using Java APIs. Please suggest if in market there are any Java APIs available for the same I checked POI but that's not much extensive. Please reply me with solutions Thanks!! ~Aman

  • Pathetic support from Lencare

    I have purchased Lenovo AIO IdeaCenter B340 in July 2013. Within a week I found it developed white patches on the screen after an hour use. I had complained this to the shop but he advised me to go through Lenovo customer care. It took me 1 month to

  • Cant save project as a picture or PNG help!!!!

    Cant save project as a picture or PNG help!!!! i edited a wallpaper den when i try to save as a PNG the save botton is greyed out so i cant save . i just bought the app pease any help thanks.