Input date format.

Database

Input date format.

Hi ,

  I am getting input character string '9/20/2012' or '8/5/2012' of '12/9/2012 (Dates but not in proper format 'YYYY-MM-DD or 'MM/DD/YYYY').

I need to change it to 'YYYY-MM-DD' format.  Can anyone guide me to do so?

Please let me know if you require any more information.

Thanks,

Dipak Rana

1 REPLY
Senior Supporter

Re: Input date format.

There exists some UDFs from ebay available in the forum which would make life a bit easier.

The hard way - ugly code


select '9/1/2012' as c, 

              case when substr(case when index(c,'/') = 3 then c else '0'!! c end,6,1) = '/' then case when index(c,'/') = 3 then c else '0'!! c end else substr (case when index(c,'/') = 3 then c else '0'!! c end,1,3) !! '0' !! substr(case when index(c,'/') = 3 then c else '0'!! c end,4) end;