To convert CYYMMDD format to YYYYMMDD format



IBM's flagship relational database management system

To convert CYYMMDD format to YYYYMMDD format

Postby pramodnagesh73 » Sat Jul 11, 2015 3:52 am

Hello All ,

I am trying to convert a date Format (CYYMMDD) to (YYYYMMDD) format and i am using the below in my query

if its 1900512 ----> it should be 19900512 and if it is 2060516 -----> it should be 20060516

CAST(CASE WHEN SUBSTRING(RIGHT('00'+ CAST(A.BIRTH_DT AS VARCHAR), -
7),1,1)='1' THEN '19' ELSE '20' END + -
SUBSTRING(RIGHT('00' + CAST(A.BIRTH_DT AS VARCHAR), 7), 2,2) -
+ SUBSTRING(RIGHT('00'+ CAST(A.BIRTH_DT AS VARCHAR),7),4,4)AS DATE) -
AS CONVERTED DATE,

But i am getting a -604 error code . Please can you let me know the issue in the above

Regards
Nagesh
pramodnagesh73
 
Posts: 5
Joined: Tue May 13, 2014 10:22 pm
Has thanked: 0 time
Been thanked: 0 time

Re: To convert CYYMMDD format to YYYYMMDD format

 

Return to DB2

 


  • Related topics
    Replies
    Views
    Last post