Page 1 of 1

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

Posted: Thu Nov 15, 2012 11:56 am
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

Posted: Thu Nov 15, 2012 12:39 pm
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.