Page 1 of 1

How can I remove dashes in a date format?

Posted: Wed Jan 28, 2009 1:22 am
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 **

Re: date conversion

Posted: Wed Jan 28, 2009 1:29 am
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

Re: date conversion

Posted: Wed Jan 28, 2009 4:47 am
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]

Posted: Wed Jan 28, 2009 5:25 am
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

Posted: Wed Jan 28, 2009 2:39 pm
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.

Posted: Wed Jan 28, 2009 3:09 pm
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:

Posted: Wed Jan 28, 2009 3:49 pm
by DSguru2B
You are absolutely right Craig. Just an OCONV with "MCN" will do the trick.

Posted: Wed Jan 28, 2009 7:29 pm
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)