Convert String(YYYYMMDD) to String(DD/MM/YYYY)

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
srini.dw
Premium Member
Premium Member
Posts: 186
Joined: Fri Aug 18, 2006 1:59 am
Location: Chennai

Convert String(YYYYMMDD) to String(DD/MM/YYYY)

Post by srini.dw »

Hi,

Date value coming from source as YYYYMMDD Varchar( 8 ).It's need to be convert as DD/MM/YYYY Varchar(10).Please let me know the function to be used for specified format.

Thanks,
Srini
banactp
Participant
Posts: 52
Joined: Tue Feb 22, 2005 2:55 pm

Post by banactp »

You could use:

DateToString(StringToDate(link.FROM_DT,"yyyymmdd"),"dd/mm/yyyy")

or:

Right(link.FROM_DT,2) : "/" : Left(Right(link.FROM_DT,4),2) : "/" : Left(link.FROM_DT,4)

or:

link.FROM_DT[7,2] : "/" : link.FROM_DT[5,2] : "/" : link.FROM_DT[1,4]

which ever you prefer. I would not be concerned about the relative efficiency of each method, and would use the first construct to show exactly why you're doing what you're doing and to take advantage of the error checking built-in to the date conversion functions.
Post Reply