Hi,
I'm having a problem with dates, I have a date in the format of:
yyyy-mm-dd 00:00:00
I need to convert it into the follwoing format:
dd/mm/yyyy 00:00:00
Can anyone help me?? These date conversions are driving me crazy!!!
Thanks
Willo
Date conversion
Moderators: chulett, rschirm, roy
Iconv and Oconv are your friends and are usually used together. If you search in this forum for them, you'll see there are a ton of posts discussing date formatting issues and resolutions.
This should get you started but will need to be modified to handle the time portion. The Status function can be used to check for success of either conversion.
You can also check out the Date routines in your 'sdk' folder for examples of using these functions.
Code: Select all
Oconv(Iconv(field_name,"D-YMD[4,2,2]"),"D/DMY[2,2,4]"
You can also check out the Date routines in your 'sdk' folder for examples of using these functions.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Well, if the time portion is always zero you could cheat. Convert the Date and then append a zero time string at the end of it.
If you want to do it right, use the FIELD command to break the string up into its Date and Time portions. Convert the Date and then stick the time back on the end afterwards. Make this reusable by writing a Routine to do this.
That help?
If you want to do it right, use the FIELD command to break the string up into its Date and Time portions. Convert the Date and then stick the time back on the end afterwards. Make this reusable by writing a Routine to do this.
That help?
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 11
- Joined: Fri Nov 07, 2003 11:14 am
As an alternative to using the inner/outer conversion functions, why not just process the date using string manipulation:
should perform the conversion you require.
Although this might be slow (?)
David
Code: Select all
MyDate[9,2]:'/':MyDate[6,2]:'/':MyDate[1,4]:MyDate[11,9]
Although this might be slow (?)
David
Hi,
I guess this is pretty long piece of derivation, but it gets the job done..
Oconv(Iconv(field(<linkname.columnname>, " ", 1, 1), "D-YMD[4,2,2]"), "D/DMY[2,2,4]"):" ":field(<linkname.columnname>, " ", 2, 3)
if you need to get it written into oracle table, then i would suggest you prefix this with
DateTimeStampToOraOCIWithTime(DateGenericToTimeStamp(<piece of code shown above>))
Hope this helps you..it worked for me
I guess this is pretty long piece of derivation, but it gets the job done..
Oconv(Iconv(field(<linkname.columnname>, " ", 1, 1), "D-YMD[4,2,2]"), "D/DMY[2,2,4]"):" ":field(<linkname.columnname>, " ", 2, 3)
if you need to get it written into oracle table, then i would suggest you prefix this with
DateTimeStampToOraOCIWithTime(DateGenericToTimeStamp(<piece of code shown above>))
Hope this helps you..it worked for me
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
It's not cheating, since DataStage is a "data type free environment".Willo wrote:Cheers guys that code works, I was tempted by chulett's suggestion of trimming the timestamp but that would be cheating!!
And it may be quicker!
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.