I need to reformat string to date in job parameters

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
vishu19aug
Participant
Posts: 39
Joined: Mon Feb 13, 2012 1:30 pm

I need to reformat string to date in job parameters

Post by vishu19aug »

Hi,

I have a situation, where i need to convert the string to date in job parameters. I am passing the date in a job parameter as '01-Jan-2012' but the parameter is defined as string. I need to extract '20120101' from this parameter and use it in the file name. Can somebody help ?

Thanks,
Vishal Gupta
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Pass the date string into a job sequence as a parameter, reformat the date within a User Variable activity stage, and then call the job passing the reformatted date string in the job's date parameter.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
vishu19aug
Participant
Posts: 39
Joined: Mon Feb 13, 2012 1:30 pm

Post by vishu19aug »

Any idea which function to use for converting string to date in user activity stage? It be a great help
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Use ICONV to convert the provided date to internal format, then OCONV to convert the converted date to the format you desire.

Code: Select all

Convert("/","",OCONV(ICONV(DateParameter,"D-"),"D/YMD[4,2,2]"))
should work, given the source and desired results you provided.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

Code: Select all

OCONV(ICONV(DateParameter,"D-"),"DYMD[4'',2'',2'']"))
Slight tweak to avoid the convert. (I'm assuming "D-" handles Jan/Feb etc as never dealing with such formats I have no idea).

Regarding OP, why all the different date string formats? Consistency through your jobs would be easier (I can understand potential differences from sources but with parameters?)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

My preference would be:

Code: Select all

Oconv(Iconv(jpStringDate, "D"), "DYMD[4,2,2]" : @VM : "MCN")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vishu19aug
Participant
Posts: 39
Joined: Mon Feb 13, 2012 1:30 pm

Thanks! All

Post by vishu19aug »

Thanks! all .. it worked perfectly.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

I figured there were better/other ways to accomplish it than my example...I just don't do server/BASIC often enough :)
- james wiles


All generalizations are false, including this one - Mark Twain.
Post Reply