Adding current Date with the file

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

Moderators: chulett, rschirm, roy

karthi_gana
Premium Member
Premium Member
Posts: 729
Joined: Tue Apr 28, 2009 10:49 pm

Post by karthi_gana »

priyadarshikunal wrote:After selecting ExecDOS you need to pass the command to execute in the text box in-front of it. so that the routine ExecDOS can execute it.
which command will give the current date?

My requirement is i have to add the current date at the end of the file.

if i run today then today's date, if i run tomorrow then tomorrow's date.
Karthik
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

use a move command in ExecDOS where the second parameter should be

Code: Select all

<filename>%date:~6,4%%date:~3,2%%date:~0,2%.txt
hope this helps.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
karthi_gana
Premium Member
Premium Member
Posts: 729
Joined: Tue Apr 28, 2009 10:49 pm

Post by karthi_gana »

priyadarshikunal wrote:use a move command in ExecDOS where the second parameter should be

Code: Select all

<filename>%date:~6,4%%date:~3,2%%date:~0,2%.txt
hope this helps.
1) I have declared a variable in the Parameter like

Parameter DefaultValue
FileName MSDFF

2) I choosed 'ExecDOS' from after subroutine(Transformer stage).

3) I gave the below value in the INPUT VALUE combo box.

MOVE #FileName# MSDFF%date:~6,4%%date:~3,2%%date:~0,2%.txt

is this correct?

I got the below error message.

ALRT_A01..tr_xc (ExecDOS): Error when executing command: MOVE MSDFF MSDFF%date:~6,4%%date:~3,2%%date:~0,2%.txt
*** Output from command was: ***
The syntax of the command is incorrect.
Karthik
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

* * REPOSTING * *

Try something like

Code: Select all

  move yourFileName yourFileName#pCurrentDate# 

where pCurrentDate is the date parameter formatted in required manner.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

First off, you need to do it after job not after stage. Secondly, you need a valid DOS command for the task - use rename rather than move. Get it working from a cmd prompt then add it to the job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

I cannot test it from datastage job as I am on unix box. But on command prompt
MOVE MSDFF MSDFF%date:~6,4%%date:~3,2%%date:~0,2%.txt
works fine and a file called MSDFF20090702.txt got created.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

if by any chance datastage is not allowing it to execute, create a job parameter pCurrentDate and from sequence job you can pass formatted date using combination of Date() and field() function.

and execute a rename command in after job ExecDOS using this parameter similar to Sainath's suggestion with Craig's suggestion implemented in it. something like

rename yourFileName yourFileName#pCurrentDate#
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Technically, 'move' is for moving a file from one drive letter / location to another and 'rename' just renames a file in place. With a UNIX background you might gravitate to 'move' but 'rename' would be more appropriate even if the other can be made to work.
-craig

"You can never have too many knives" -- Logan Nine Fingers
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

@Craig

I agree.

@karthi_gana

Just noticed : where is the path?

you need to provide a fully qualified path of the file to run the command. Computer is not so intelligent to find that file for you before renaming or moving it.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
Post Reply