Page 1 of 1

Date formatting

Posted: Thu Jul 27, 2006 6:51 am
by Shree0410
hi guyz,

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

thanks

Posted: Thu Jul 27, 2006 6:54 am
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.

Posted: Thu Jul 27, 2006 6:57 am
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

Posted: Thu Jul 27, 2006 7:06 am
by Shree0410
i don't want to convert the format, i just want to remove '/''s from the date..

Posted: Thu Jul 27, 2006 7:09 am
by loveojha2
You can try ereplace.
You can try Iconv, Oconv. What else you want. :lol:

Posted: Thu Jul 27, 2006 7:09 am
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.

Posted: Thu Jul 27, 2006 11:01 am
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]

Posted: Thu Jul 27, 2006 3:30 pm
by ray.wurlod
Oh, there is so too!

Code: Select all

Oconv(internal_date, "D/YMD[4,2,2]" : @VM : "MCN")

Posted: Thu Jul 27, 2006 4:20 pm
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.

Posted: Mon Mar 09, 2015 9:23 am
by oracledba
Convert("/:","",Oconv(Iconv(internal_date, "D2/"),"DYMD[4,2,2]"))

Posted: Mon Mar 09, 2015 9:53 am
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".

Posted: Mon Mar 09, 2015 10:21 am
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.