Page 1 of 1

Adding date parameter to batch file

Posted: Thu Feb 25, 2016 12:33 pm
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!!

Posted: Thu Feb 25, 2016 2:23 pm
by chulett
Use the Convert() function to strip them from the field by replacing them with '' - an empty string.

Posted: Thu Feb 25, 2016 2:34 pm
by ray.wurlod

Code: Select all

Oconv(Date(), "DYMD[4,2,2]" : @VM : "MCN")

Posted: Thu Feb 25, 2016 2:43 pm
by Childrensmn
This did it. Thanks!!

Posted: Thu Feb 25, 2016 3:06 pm
by chulett
Do you understand how that 'did it'?

Posted: Thu Feb 25, 2016 4:38 pm
by ray.wurlod
I have explained the technique in the past on DSXchange. If there's enough interest, I could reprise that explanation.

Posted: Sun Feb 28, 2016 10:36 am
by Childrensmn
Yes. I searched and got the explanation.