My code:
Trim('04/01/2009'[1,2], '0','L') :'-' : Trim('04/01/2009'[4,2], '0','L') :'-': Right('04/01/2009',2)
Output will be 4/1/09.
Instead of using this lengthy code can we convert the source string to date and then back to string to get just as '4/1/09'. Or please let me know if there is any other way.
Conversion to and from date would do it, but it will be far more complex than your substring-based solution. You need appropriate format strings in each case. What happens when day or month needs two digits?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
My code:
Trim('04/01/2009'[1,2], '0','L') :'-' : Trim('04/01/2009'[4,2], '0','L') :'-': Right('04/01/2009',2)
Output will be 4/1/09.
Instead of using this lengthy code can we convert the source string to date and then back to string to get just as '4/1/09'. Or please let me know if there is any other way.