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: Help with my to_date function

Re: Help with my to_date function

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 2 Oct 2006 06:36:27 -0700
Message-ID: <1159796187.426077.40360@c28g2000cwb.googlegroups.com>

emdproduction_at_hotmail.com wrote:
> Group,
>
> I need to change a string of 6 in the format of 'yymmdd' to date. If
> yy< 07, i need to put 20 in front of it. If yy<07, I need to put 19 in
> front of it.
>
> So,
> 040102 needs to be 20040102
> while
> 320102 needs to be 19320102.
>
> Thanks for your help.

So what is the problem?

UT1 > select
  2 to_date(case when substr('040102',1,2) < '07' then '20'||'040102'

  3                                               else '19'||'040102'
  4            end, 'YYYYMMDD')

  5 from sys.dual
  6 /

TO_DATE(C



02-JAN-04 UT1 > select
  2 to_date(case when substr('320102',1,2) < '07' then '20'||'320102'
  3                                               else '19'||'320102'
  4            end, 'YYYYMMDD')

  5 from sys.dual
  6 /

TO_DATE(C



02-JAN-32 You use to_date to convert character input into a rdbms date column value and you use to_char to format the output just about any way you want. See the SQL manual entries for the functions.

HTH -- Mark D Powell -- Received on Mon Oct 02 2006 - 08:36:27 CDT

Original text of this message

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