Date formatting

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Shree0410
Participant
Posts: 70
Joined: Tue Nov 29, 2005 7:25 pm

Date formatting

Post by Shree0410 »

hi guyz,

How can I remove the '/' from a date field in a transformation.

thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Lots of ways. You could substring it apart around the slashes and put it back together with them. You could use your favorite function like Convert, Ereplace or Change to simply remove them from the field.

Suggest you give Convert a try.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ashwin141
Participant
Posts: 95
Joined: Wed Aug 24, 2005 2:26 am
Location: London, UK

Post by ashwin141 »

Hi

In addition to what all Craig suggested you can simply convert the date from one format to other, if that is what you intend to do by removing '/' from date.



Regards
Ashwin
Shree0410
Participant
Posts: 70
Joined: Tue Nov 29, 2005 7:25 pm

Post by Shree0410 »

i don't want to convert the format, i just want to remove '/''s from the date..
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

You can try ereplace.
You can try Iconv, Oconv. What else you want. :lol:
Last edited by loveojha2 on Thu Jul 27, 2006 7:10 am, edited 1 time in total.
Success consists of getting up just one more time than you fall.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Check the help, the Convert function converts one character into another. In your case, converting the slashes to an empty string removes them from the field.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

ashwin141 wrote:...simply convert the date from one format to other...
Unfortunately as there is no OCONV() date format that has no separator, it will always output some sort of character; no OCONV() code will output yyyymmdd or similar formats. You will need to use CONVERT('/','',DateString) to remove forward slashes [or another string function of your choosing]
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Oh, there is so too!

Code: Select all

Oconv(internal_date, "D/YMD[4,2,2]" : @VM : "MCN")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

But Ray - that is cheating :shock: . All the date OCONV()s produce a separator, the use of two conversion formats just "internalizes" the stripping of the characters.
oracledba
Premium Member
Premium Member
Posts: 49
Joined: Mon Aug 06, 2012 9:21 am

Post by oracledba »

Convert("/:","",Oconv(Iconv(internal_date, "D2/"),"DYMD[4,2,2]"))
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

oracledba wrote:Convert("/:","",Oconv(Iconv(internal_date, "D2/"),"DYMD[4,2,2]"))
So... basically the same answer as posted in 2006 with semicolons added to the strip list (it's a date not a date/time) and an unnecessary IConv thrown in for some reason... if you are truly dealing with an internal date. However, if this date has slashes in it then it's already in external format stored in a string so heck - we shouldn't even need the OConv. They did note they didn't need anything converted, just asked how to remove the existing slashes. :wink:

Of course, all this is predicated by what Shree0410 meant by a "date field".
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Just wanted to add that the good thing (or perhaps bad thing) about the Conv conversions is that if you do something invalid they typically don't throw an error but rather pass the original value through unchanged. Which is why doing an 'unnecessary' IConv on an internal date seems to work properly.

From what I recall, there is a STATUS function you can call immediately after a conversion call to determine if it was successful or if not, why. Ah yes, here it is:

http://www-01.ibm.com/support/knowledge ... ction.html

Copy/paste the entire URL into your browser.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply