All Forums Database
dipakrana 2 posts Joined 10/11
02 Aug 2012
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

ulrich 816 posts Joined 09/09
02 Aug 2012

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;

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

You must sign in to leave a comment.