Page 1 of 2

Adding current Date with the file

Posted: Wed Jul 01, 2009 4:08 am
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 ?

Posted: Wed Jul 01, 2009 4:32 am
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.

Posted: Wed Jul 01, 2009 5:39 am
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.

Posted: Wed Jul 01, 2009 11:16 am
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.

Posted: Wed Jul 01, 2009 12:05 pm
by chulett
That's cool, Daddy-o as long as you don't mind the delimiters the macros use. :wink:

Posted: Wed Jul 01, 2009 4:20 pm
by ray.wurlod
Maynard G Krebs lives!
:roll:

Posted: Wed Jul 01, 2009 4:50 pm
by chulett
Wasn't that Gilligan before he was Gilligan... <google,google>... why yes, yes it was. 8)

Posted: Thu Jul 02, 2009 1:18 am
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.

Posted: Thu Jul 02, 2009 2:35 am
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.

Posted: Thu Jul 02, 2009 3:33 am
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 ?

Posted: Thu Jul 02, 2009 4:29 am
by Sainath.Srinivasan
execSH

Posted: Thu Jul 02, 2009 5:23 am
by chulett
From a Windows server it would be ExecDOS. And code in 'Job Control' is not visible to anything inside your job proper.

Posted: Thu Jul 02, 2009 6:51 am
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.

Posted: Thu Jul 02, 2009 6:55 am
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.

Posted: Thu Jul 02, 2009 7:03 am
by Sainath.Srinivasan
Try something like

Code: Select all

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