Page 1 of 1

Date conversion

Posted: Tue Oct 21, 2008 11:33 pm
by sujaoschin
My input column 'AC_COMPLETED' is in the date format of '20060801'. How to convert this string into the date format of '01/08/2008'

Posted: Wed Oct 22, 2008 1:01 am
by DS_SUPPORT
Search the forum for OCONV or look into help for OCONV

Posted: Wed Oct 22, 2008 7:38 am
by chulett
Going that route, you'd need both IConv and OConv. First convert the data to internal format and then back to external format using the desired mask.

If your date is consistent, meaning always 8 digits, you can also go the substring route:

Code: Select all

Link.AC_COMPLETED[7,2] : '/' : Link.AC_COMPLETED[5,2] : '/' : Link.AC_COMPLETED[1,4]

Posted: Wed Oct 22, 2008 5:50 pm
by ray.wurlod
Did you mean '01/08/2006'? If not, what is your business rule for date arithmetic?

Posted: Thu Oct 23, 2008 6:41 pm
by sujaoschin
Ray,

Incoming date is in the format of 20081001 and business wants to see in the format of '01/10/2008'.

Chulett,

I did as per your suggestion as the incoming date is always having 8 digits. It is working fine. Thank you so much.

DEFAULT.AC_COMPLETED[7,2]:'/':DEFAULT.AC_COMPLETED[5,2]:'/':DEFAULT.AC_COMPLETED[1,4]

Re: Date conversion

Posted: Thu Oct 23, 2008 9:39 pm
by ray.wurlod
sujaoschin wrote:My input column 'AC_COMPLETED' is in the date format of '20060801'.
This was the cause of my question, of course.