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: to_date

Re: to_date

From: Michel Cadot <micadot_at_netcourrier.com>
Date: 2000/07/27
Message-ID: <8lp1ki$20gn$1@s2.feed.news.oleane.net>#1/1

You can create a function, for instance:

v734> create or replace function check_date (in_date in varchar2)   2 return date is
  3 my_date date;
  4 begin

  5     my_date := to_date (in_date, 'DD/MM/YYYY');
  6     return my_date;
  7  exception
  8     when others then
  9        raise_application_error (-20000, 'Wrong date format');
 10 end;
 11 /

Function created.

v734> select to_char(check_date('01/01/2000'),'DD-MON-YY') from dual;

TO_CHAR(CHECK_DATE('01/01/2000'),'DD-MON-YY')



01-JAN-00 1 row selected.

v734> select to_char(check_date('32-JAN-0'),'DD-MON-YY') from dual; ERROR:

ORA-20000: Wrong date format
ORA-06512: at "MMA$EP34087.CHECK_DATE", line 9
ORA-06512: at line 1

--
Have a nice day
Michel


Sandy <daleelaNOdaSPAM_at_usa.net.invalid> a écrit dans le message :
32bd4fa0.54ab8325_at_usw-ex0109-068.remarq.com...

> i want to check if a date is correct and i would like to
> know how to do : my date must be like this DD/MM/YYYY and
> whatever characters would be entered i would like to check
> if it is a date in the format DD/MM/YYYY.
>
> thanks
>
> sandy
>
>
> * Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images,
Audios, Videos, News, and Shopping. Smart is Beautiful
Received on Thu Jul 27 2000 - 00:00:00 CDT

Original text of this message

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