Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Use of to_date function

Re: Use of to_date function

From: H. Fellinghauer <hfr-NOSPAM-_at_metzler.com>
Date: 1997/11/19
Message-ID: <3472AA92.5FCF@metzler.com>#1/1

stamp.dean_at_corona.navy.mil wrote:
>
> Does anybody know if you can use the to_date function to select on both a
> date and time without typing in the format? For example, I want to do:
>
> select datetime from a.view where datetime = to_date('05-AUG-97 11:13:42')
>
> without having to type in the extra ,'DD-MON-YY HH:MI:SS'). I found out
> you don't have to type in the format portion when you just enter a date.
> For example, the following works:
>
> select datetime from a.view where datetime = to_date('05-AUG-97')
>
> but, of course, in this case you only get records occurring at time
> 00:00:00. Thanks for any help or if you can direct me where to go to get
> further information.
>
> -------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
Set your NLS_DATE_FORMAT parameter to whatever is appropriate for you, e.g.:
  NLS_DATE_FORMAT='DD.MM.YYYY HH24:MI:SS' You can do so within your configuration (registry on Win NT) or with the following statement:
  ALTER SESSION SET NLS_DATE_FORMAT='DD.MM.YYYY HH24:MI:SS'; Ask your DBA for ALTER SESSION permissions granted.

If done, you can run your first select statement as follows:   select datetime from a.view where datetime = '05.07.1997 11:13:42');

BTW, your syntax specified isn't right:
  select datetime from a.view where datetime = to_date('05-AUG-97 11:13:42')
must be written as
  select datetime from a.view where to_date(datetime,'dd-mon-yy hh:mi:ss') =

    '05-AUG-97 11:13:42'; HTH.
  Harry

-- 
                                                      ///
  Hiroshima '45   Chernobyl '86   Windows '95        (O O)
-------------------------------------------------oOO--(_)--OOo---------
  "There is more than one way to do it!"

(Remove -NOSPAM- from my email address)
Received on Wed Nov 19 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US