Date conversion

Archive of postings to DataStageUsers@Oliver.com. This forum intended only as a reference and cannot be posted to.

Moderators: chulett, rschirm

Locked
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Date conversion

Post by admin »

Hi all,

I have to convert internal date (@DATE) in YYYYMMDD. I tried Oconv function in this way:

Ans = Oconv(@DATE, "DYMD[4,2,2]")

but the deault separation character (blank) betwen year month and day, produce the following result:

YYYY MM DD

My rough solution was to replace blanks with "" :-(

Ans = Ereplace(Oconv(@DATE, "DYMD[4,2,2]"), " ", "")

Does exist a better way to obtain this result (ex. a correct format string as Oconv argument)?


Thanks,



Alessio
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Ans = Oconv(@DATE, "DYMD[4,2,2]":@VM:"MCN")

The expression editor may object to @VM as not a valid system variable. However, it is, and will compile successfully. If you dont like the red colour, edit the DSParams file on the server (in your project directory) to include @VM in the [System Variables] section.

-----Original Message-----
From: Alessio Giordani [mailto:alessio.giordani@inwind.it]
Sent: Friday, 14 September 2001 17:59
To: datastage-users@oliver.com
Subject: Date conversion


Hi all,

I have to convert internal date (@DATE) in YYYYMMDD. I tried Oconv function in this way:

Ans = Oconv(@DATE, "DYMD[4,2,2]")

but the deault separation character (blank) betwen year month and day, produce the following result:

YYYY MM DD

My rough solution was to replace blanks with "" :-(

Ans = Ereplace(Oconv(@DATE, "DYMD[4,2,2]"), " ", "")

Does exist a better way to obtain this result (ex. a correct format string as Oconv argument)?


Thanks,



Alessio
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

How about:

Ans = Oconv(@DATE, "DYMD[4,2,2]")

Regards

- Chris Thornton

-----Original Message-----
From: Alessio Giordani [mailto:alessio.giordani@inwind.it]
Sent: 14 September 2001 08:59
To: datastage-users@oliver.com
Subject: Date conversion


Hi all,

I have to convert internal date (@DATE) in YYYYMMDD. I tried Oconv function in this way:

Ans = Oconv(@DATE, "DYMD[4,2,2]")

but the deault separation character (blank) betwen year month and day, produce the following result:

YYYY MM DD

My rough solution was to replace blanks with "" :-(

Ans = Ereplace(Oconv(@DATE, "DYMD[4,2,2]"), " ", "")

Does exist a better way to obtain this result (ex. a correct format string as Oconv argument)?


Thanks,



Alessio
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Strictly, you dont need that last , the following should be enough since only 2 separators need to be defined (or undefined in this case!), between Y & M and between M & D:-

Ans = Oconv(@DATE, "DYMD[4,2,2")

> -----Original Message-----
> From: chris.thornton@ascentialsoftware.com
> [mailto:chris.thornton@ascentialsoftware.com]
> Sent: Friday, September 14, 2001 9:20 AM
> To: datastage-users@oliver.com
> Subject: RE: Date conversion
>
>
>
>
> How about:
>
> Ans = Oconv(@DATE, "DYMD[4,2,2]")
>
> Regards
>
> - Chris Thornton
>
> -----Original Message-----
> From: Alessio Giordani [mailto:alessio.giordani@inwind.it]
> Sent: 14 September 2001 08:59
> To: datastage-users@oliver.com
> Subject: Date conversion
>
>
> Hi all,
>
> I have to convert internal date (@DATE) in YYYYMMDD. I tried Oconv
> function in this way:
>
> Ans = Oconv(@DATE, "DYMD[4,2,2]")
>
> but the deault separation character (blank) betwen year month and day,
> produce the following result:
>
> YYYY MM DD
>
> My rough solution was to replace blanks with "" :-(
>
> Ans = Ereplace(Oconv(@DATE, "DYMD[4,2,2]"), " ", "")
>
> Does exist a better way to obtain this result (ex. a correct
> format string
> as Oconv argument)?
>
>
> Thanks,
>
>
>
> Alessio
>
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Thanks a lot!

Both kinds of solution work fine!

Alessio



----- Original Message -----
From:
To:
Sent: Friday, September 14, 2001 11:09 AM
Subject: RE: Date conversion


> Strictly, you dont need that last , the following should be enough
> since only 2 separators need to be defined (or undefined in this
> case!), between Y & M and between M & D:-
>
> Ans = Oconv(@DATE, "DYMD[4,2,2")
>
> > -----Original Message-----
> > From: chris.thornton@ascentialsoftware.com
> > [mailto:chris.thornton@ascentialsoftware.com]
> > Sent: Friday, September 14, 2001 9:20 AM
> > To: datastage-users@oliver.com
> > Subject: RE: Date conversion
> >
> >
> >
> >
> > How about:
> >
> > Ans = Oconv(@DATE, "DYMD[4,2,2]")
> >
> > Regards
> >
> > - Chris Thornton
> >
> > -----Original Message-----
> > From: Alessio Giordani [mailto:alessio.giordani@inwind.it]
> > Sent: 14 September 2001 08:59
> > To: datastage-users@oliver.com
> > Subject: Date conversion
> >
> >
> > Hi all,
> >
> > I have to convert internal date (@DATE) in YYYYMMDD. I tried Oconv
> > function in this way:
> >
> > Ans = Oconv(@DATE, "DYMD[4,2,2]")
> >
> > but the deault separation character (blank) betwen year month and
> > day, produce the following result:
> >
> > YYYY MM DD
> >
> > My rough solution was to replace blanks with "" :-(
> >
> > Ans = Ereplace(Oconv(@DATE, "DYMD[4,2,2]"), " ", "")
> >
> > Does exist a better way to obtain this result (ex. a correct
> > format string
> > as Oconv argument)?
> >
> >
> > Thanks,
> >
> >
> >
> > Alessio
> >
>
Locked