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

Adding current Date with the file

Post by karthi_gana »

All,

I have create a job which will extract the data from a table and store it in a text file.

say for example,

Table Name: Emp

I want to add current date at the end of file. i.e if i run the job now, the file should be created as e_details20090701.txt

suppose if i run the job tomorrow,then the file name should be
e_details20090702.txt.

How to add the current date at the end of file ?
Karthik
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The date portion of the filename should be passed into the job as a job parameter. It is not quite clear to me whether this date is part of the data or computed elsewhere, though.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

This has been asked and answered a jillion times here. Another way - create it with a fixed name and then rename it to include the date 'after job' using your O/S.
-craig

"You can never have too many knives" -- Logan Nine Fingers
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

Jillion+1. That method too complicated and too Old School. Get Hip Daddy-O. Use a DSMacro as part of the filename in the sequential stage. <filename>#DSJobStartDate#. Use DSJobStartTimestamp if running more then once in a day. Nah, never happen.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That's cool, Daddy-o as long as you don't mind the delimiters the macros use. :wink:
-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 »

Maynard G Krebs lives!
:roll:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Wasn't that Gilligan before he was Gilligan... <google,google>... why yes, yes it was. 8)
-craig

"You can never have too many knives" -- Logan Nine Fingers
karthi_gana
Premium Member
Premium Member
Posts: 729
Joined: Tue Apr 28, 2009 10:49 pm

Post by karthi_gana »

throbinson wrote:Jillion+1. That method too complicated and too Old School. Get Hip Daddy-O. Use a DSMacro as part of the filename in the sequential stage. <filename>#DSJobStartDate#. Use DSJobStartTimestamp if running more then once in a day. Nah, never happen.
I gave like

#FileName##DSJobStartDate# but the date didn't added with the file name.

I declared one variable in the parameter

ProcessDate

with default value

1000-01-01


In the JobControl section,

I wrote one subroutine

If ProcessDate = "1000-01-01" Then ProcessDate = Oconv(Date(),"D-YMD[4,2,2]")

then i used this variable like

#FileName##ProcessDate#

But no use.
Karthik
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Timestamps has colon (:) symbol which is generally interpretted for remote hostname or ip address.

Parameter must not be computed within the job.

Use an afterjob rountine for now.
karthi_gana
Premium Member
Premium Member
Posts: 729
Joined: Tue Apr 28, 2009 10:49 pm

Post by karthi_gana »

Sainath.Srinivasan wrote:Timestamps has colon (:) symbol which is generally interpretted for remote hostname or ip address.

Parameter must not be computed within the job.

Use an afterjob rountine for now. ...
What i have to choose from the afterjob routine combo box ?
Karthik
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

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

Post by chulett »

From a Windows server it would be ExecDOS. And code in 'Job Control' is not visible to anything inside your job proper.
-craig

"You can never have too many knives" -- Logan Nine Fingers
karthi_gana
Premium Member
Premium Member
Posts: 729
Joined: Tue Apr 28, 2009 10:49 pm

Post by karthi_gana »

chulett wrote:From a Windows server it would be ExecDOS. And code in 'Job Control' is not visible to anything inside your job proper. ...
It is throwing 'No command to execute' error message.
Karthik
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

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.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Try something like

Code: Select all

  move yourFileName yourFileName#pCurrentDate#
where pCurrentDate is the date parameter formatted in required manner.
Post Reply