Naming a file with the current timestamp?

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
SHARAD123
Premium Member
Premium Member
Posts: 54
Joined: Wed Jan 09, 2008 12:05 am

Naming a file with the current timestamp?

Post by SHARAD123 »

Hi all,
How to have a file name as the timestamp?

For example:
The file name should be
20070802213012.txt
222102
WoMaWil
Participant
Posts: 482
Joined: Thu Mar 13, 2003 7:17 am
Location: Amsterdam

Post by WoMaWil »

It depends how fine you want to have the timestamp. If you pass while starting your job the date/time as a parameter you are able to use it for the file naming.
Wolfgang Hürter
Amsterdam
asitagrawal
Premium Member
Premium Member
Posts: 273
Joined: Wed Oct 18, 2006 12:20 pm
Location: Porto

Post by asitagrawal »

Timestamp and OConv, IConv can be combined together to acheive the results...
Share to Learn, and Learn to Share.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or write it out with a static name and then 'after job' rename it using your O/S, adding a timestamp in the process.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Nirmala84
Participant
Posts: 3
Joined: Thu Jan 10, 2008 7:02 am

Using Job Parameters

Post by Nirmala84 »

Hi,

When you use a parallel extender, there s an option to include job parameter for the file name.

1) Declare a job parameter of time type.
2) Use that inside the filename column.

I think this would solve the problem.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Parallel or Server, you can always use a job parameter for part or all of a filename.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Use the macro "DSJobStartTimestamp" enclosed in hashes with the file name. You will not get the format you want, but it will get you your timestamp.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Post by paddu »

Just a suggestion .

I have similar requirement and did something as below.

Achieved in Job sequence.

1) Used UserVariables activity stage(named as UV_FileDate) which passes timestamp as parameter FileDate

OCONV(@DATE, "D4YMD[4,2,2]"):'':Ereplace(OCONV(@TIME,"MT"),':','') to the job activity stage .

2) Filename in the job activity stage looks like this
'Products_':Ereplace(UV_FileDate.FileDate,'/',''):'.CSV'

Hope this information is of any help.
Thanks
Paddu
baglasumit21
Participant
Posts: 132
Joined: Wed Mar 01, 2006 11:12 pm
Location: Pune

Post by baglasumit21 »

paddu wrote:Just a suggestion .

I have similar requirement and did something as below.

Achieved in Job sequence.

1) Used UserVariables activity stage(named as UV_FileDate) which passes timestamp as parameter FileDate

OCONV(@DATE, "D4YMD[4,2,2]"):'':Ereplace(OCONV(@TIME,"MT"),':','') to the job activity stage .

2) Filename in the job activity stage looks like this
'Products_':Ereplace(UV_FileDate.FileDate,'/',''):'.CSV'

Hope this information is of any help.
Thanks
Paddu
Even it is achievable using unix script in a after job routine where in you can rename the file to attach the timestamp part to it. We have done this in one of our job.
SMB
Post Reply