How can I remove dashes in a date format?

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
Virupan
Participant
Posts: 5
Joined: Fri Jan 11, 2008 4:18 am

How can I remove dashes in a date format?

Post by Virupan »

Hi,

How can I convert date format from 'yyyy-mm-dd' to 'yyyymmdd' format ? Which is the date function to be used.Please let me know.


Thanks

**Note: Subject changed to be more descriptive - Content Editor **
swarnkar
Participant
Posts: 74
Joined: Wed Jan 11, 2006 2:22 am

Re: date conversion

Post by swarnkar »

[quote="Virupan"]Hi,

How can I convert date format from 'yyyy-mm-dd' to 'yyyymmdd' format ?

You can delete " - " by using EREPLACE function

EREPLACE(columnName,"-","")

Nitin Swarnkar
akarsh
Participant
Posts: 51
Joined: Fri May 09, 2008 4:03 am
Location: Pune

Re: date conversion

Post by akarsh »

swarnkar wrote:
Virupan wrote:Hi,

How can I convert date format from 'yyyy-mm-dd' to 'yyyymmdd' format ?

You can delete " - " by using EREPLACE function

EREPLACE(columnName,"-","")

Nitin Swarnkar
u can also do like

date[1,4]:date[6,2]:date[9,2]
Thanks,
Akarsh Kapoor
mk_ds09
Participant
Posts: 72
Joined: Sun Jan 25, 2009 4:50 pm
Location: Pune

Post by mk_ds09 »

u can use trim also to remove the '-' ..
Use option as 'A'..

if you want to do it in unix ..use cut -c

hope this helps

--
Mk
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Or you could use the good ol' ICONV/OCONV conversions

Code: Select all

OCONV(ICONV(in.date, "D-YMD"), "DYMD":@VM:"MCN")
The second conversion code of "MCN" will strip away the spaces.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Just the OConv is all that's really needed in this case... or use the DIGITS transform which makes the same function call under the covers but is a little easier on the eyes. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You are absolutely right Craig. Just an OCONV with "MCN" will do the trick.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The most efficient way, in this particular case, is to use Convert() function to change the "-" characters to "".

Code: Select all

Convert("-", "", InLink.TheDate)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply