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
Convert String(YYYYMMDD) to String(DD/MM/YYYY)
Moderators: chulett, rschirm, roy
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.
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.