how to pass current date as filename in datastage server

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
vsandu
Participant
Posts: 13
Joined: Mon Aug 09, 2010 3:50 am

how to pass current date as filename in datastage server

Post by vsandu »

Hi ,

I want update my file name abcd_curdate.txt, once we ran the job
for ex : if we ran today abcd_20092012.txt
how we can achive please suggest on this
i am using server job and batch job, not parllel and sequence
thanks in advance
Venkat Sandu
vsandu.cg@gmail.com
pnpmarques
Participant
Posts: 35
Joined: Wed Jun 15, 2005 9:27 am

Post by pnpmarques »

If you do not want to pass the date as parameter to the job (calculated in a sequence for example), then my sugestion is to rename the file in the "after job subroutine" (Job properties).
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Agreed. Use ExecSH as the after-job subroutine, and use mv as the command, with `date +%Y%m%d` as the date part of the file name.
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 »

The batch job could very easily get the current date and pass it as a parameter... or you could rename the file after job. Both ways are perfectly valid.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

I'm currently using an approach similar to Ray's suggestions to archive files ( cpio+gzip) once they are created using unix date command with its format modifiers. works like a charm
mobashshar
Participant
Posts: 91
Joined: Wed Apr 20, 2005 7:59 pm
Location: U.S.

Post by mobashshar »

Hi,
Just use this #DSJobStartDate# at the end of the file name. So in your case the exact name for the file will be as follows:
abcd_#DSJobStartDate#.txt

Hope this helps.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As long as you don't mind the delimiters it brings to the party. I prefer an unformatted YYYYMMDD date so it sorts 'properly'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
uzl
Premium Member
Premium Member
Posts: 20
Joined: Mon Jul 23, 2012 4:33 am

Post by uzl »

I use a User Variables Activity in my sequence. Here i define the variable current_date as Oconv(@DATE,'D-YMD[4,2,2]') :'_':Oconv(@TIME,'MTS.'). This variable I pass to the job in the Job Activitythat follows the User Variables Activity.
Post Reply