Hi All,
I have date in '19960422' format and I need to convert it in '04/22/1996'.
Thanks,
markus
Date convertion
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 108
- Joined: Sat Feb 05, 2005 6:52 pm
- Location: US
Re: Date convertion
markus wrote:Hi All,
I have date in '19960422' format and I need to convert it in '04/22/1996'.
Thanks,
markus
hi all,
how to use iconv and oconv converting dates
use this
Code: Select all
Oconv(Iconv(in.date,"DYMD[4,2,2]"),"D/MDY[2,2,4]")
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Re: Date convertion
Try the following, should be pretty close to what you want:
Ogmios
Code: Select all
Oconv(Iconv(%Arg1%, "D4YMD[4,2,2]"), "D/")
In theory there's no difference between theory and practice. In practice there is.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Markus, in case you are confused, the plethora of answers results from the fact that DataStage server edition does not have data type restrictions. So some of the answers use substring and concatenation techniques (OK if you can guarantee that your dates are always YYYYMMDD format), others use date conversion functions Iconv() and Oconv() which allow for some flexibility in handling dates (for example dates with only two digit year). I would use
"DYMD" asserts that the incoming date is in year-month-day order but nothing more. "D/MDY[4,2,2]" very specifically states that the output date (string) will be in month day year order with exactly two digits for month and day, and exactly four digits for year.
Code: Select all
Oconv(Iconv(InLink.TheDate, "DYMD"), "D/MDY[2,2,4]")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.