Adding date parameter to batch file

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
Childrensmn
Premium Member
Premium Member
Posts: 32
Joined: Mon Apr 12, 2010 3:42 pm
Location: Minneapolis
Contact:

Adding date parameter to batch file

Post by Childrensmn »

Hi,

We get daily file with change in date. Example:Today's file: FILE_NAME_20160225.txt.
I will be passing this as a parm in datastage job.

TodaysDate = Oconv(Date(), "DYMD[4,2,2]");
FileString1 = 'FILE_NAME_':TodaysDate:'.txt'


I am getting date in YYYY/MM/DD format instead of YYYYMMDD format.

The above code returns: FILE_NAME_2016/02/25.txt.

Please let me know how to get the right formatted date: FILE_NAME_20160225.txt.

Thanks!!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Use the Convert() function to strip them from the field by replacing them with '' - an empty string.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Oconv(Date(), "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.
Childrensmn
Premium Member
Premium Member
Posts: 32
Joined: Mon Apr 12, 2010 3:42 pm
Location: Minneapolis
Contact:

Post by Childrensmn »

This did it. Thanks!!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Do you understand how that 'did it'?
Last edited by chulett on Thu Feb 25, 2016 4:55 pm, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I have explained the technique in the past on DSXchange. If there's enough interest, I could reprise that explanation.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Childrensmn
Premium Member
Premium Member
Posts: 32
Joined: Mon Apr 12, 2010 3:42 pm
Location: Minneapolis
Contact:

Post by Childrensmn »

Yes. I searched and got the explanation.
Post Reply