Page 1 of 1

I need to reformat string to date in job parameters

Posted: Tue Aug 07, 2012 1:57 pm
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

Posted: Tue Aug 07, 2012 2:30 pm
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,

Posted: Tue Aug 07, 2012 2:49 pm
by vishu19aug
Any idea which function to use for converting string to date in user activity stage? It be a great help

Posted: Tue Aug 07, 2012 4:03 pm
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,

Posted: Tue Aug 07, 2012 4:52 pm
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?)

Posted: Tue Aug 07, 2012 5:47 pm
by ray.wurlod
My preference would be:

Code: Select all

Oconv(Iconv(jpStringDate, "D"), "DYMD[4,2,2]" : @VM : "MCN")

Thanks! All

Posted: Tue Aug 07, 2012 8:27 pm
by vishu19aug
Thanks! all .. it worked perfectly.

Posted: Tue Aug 07, 2012 9:43 pm
by jwiles
I figured there were better/other ways to accomplish it than my example...I just don't do server/BASIC often enough :)