Extracting Long Month Name from Date

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

Seyed
Participant
Posts: 74
Joined: Wed Apr 14, 2010 7:25 am
Location: Oklahoma City

Post by Seyed »

Hello Ray,
Problem is resovled. After removing dashes and time from the timestamp, I was able to get your suggested code to work as well.

Here is how I got your suggested code to work:

Code: Select all

OConv(IConv(Change(DSLink1.LOG_DT_TM[1,10],"-",""), "G0.1" : @VM : "D"), "DMA" : @VM :"MCT")
Thank you very much for your help,

Seyed
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You shouldn't need to remove the dashes. However, since YMD is not your default locale setting, you need DYMD in the Iconv() function. Also, it's a space, not a dot, in the G conversion.

Code: Select all

OConv(IConv(DSLink1.LOG_DT_TM, "G0 1" : @VM : "DYMD"), "DMA" : @VM :"MCT")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Seyed wrote:Craig,
The problem is resolved. I followed your instructions and identified that the problem was in the Iconv routine. It turns out that I had to remove dashes from the date.

Here is how I got your suggested code to work:

Code: Select all

OConv(OConv(IConv(Change(DSLink1.LOG_DT_TM[1,10],"-",""),"D"),"DMA"),"MCT")

I ended up removing time and also dashes from date.

Thank you so much,

Seyed
For this code

for the input 2011-03-12, it returns November. It should be March right?

Thanks
pandeeswaran
Seyed
Participant
Posts: 74
Joined: Wed Apr 14, 2010 7:25 am
Location: Oklahoma City

Post by Seyed »

ray.wurlod wrote:You shouldn't need to remove the dashes. However, since YMD is not your default locale setting, you need DYMD in the Iconv() function. Also, it's a space, not a dot, in the G conversion.
Ray,
Thank you so much for the information. I will make these changes.

Seyed
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

pandeesh wrote:It should be March right?
Only if your default date format (in your locale) uses YMD order.
Note that the rules for server jobs are different from the rules for parallel jobs.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Thanks Ray! I have understood. It depends on the default Date format settings
pandeeswaran
Seyed
Participant
Posts: 74
Joined: Wed Apr 14, 2010 7:25 am
Location: Oklahoma City

Post by Seyed »

Ray,
Following your comments, I didn't remove dashes. I also changed the format in the Iconv to 'DYMD' and also replaced the the decimal with a space for the 'G' function and now the resulting code works.

Code: Select all

OConv(IConv(DSLink1.LOG_DT_TM[1,10], "G0 1" : @VM : "DYMD"), "DMA" : @VM :"MCT")
Thank you very much,

Seyed
MrBlack
Participant
Posts: 125
Joined: Wed Aug 08, 2012 8:57 am

Taking one step farther Full month to abbr month

Post by MrBlack »

ray.wurlod wrote:

Code: Select all

OConv(IConv(YourField,"D"),"DMA" : @VM :"MCT")
...
I found your post and it's given me hope to my similar problem, in your example you return a full month name, what if I just want an abbreviated month, so August would be Aug, and June would be Jun.

The Big Picture
My data is 20120808 and I'm trying to transform it to 08-AUG-2012.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

"D-YMD[4,A3,2]"
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

"D-DMBY"
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