If you're running in an after-job routine, end date/time can be obtained from the system functions Date() and Time(), or TimeDate().
Elapsed time can be obtained by getting the job's start date/time using DSGetJobInfo(DSJ.ME, DSJ.JOBSTARTTIMESTAMP) and subtracting.
Alternately, obtain the Control entries from the log (DSGetLogSummary function, then DSGetLogEntry function). The times you require are recorded in these.
Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
Function to Get End time and Elapsed Time
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Hi,
You can try this function 'DSMakeJobReport'.
It generates a string describing the complete status of a valid attached job.
There are some sample codes I wrote in a routine to capture the start time, end time, elapsed time, status and status description for jobs.
**
JobHandle = DSAttachJob(JobName, DSJ.ERRNONE)
Content = DSMakeJobReport(JobHandle, 0, 'LF')
JobStart = Field(Field(Content, Char(10), 5), '=', 2)
JobEnd = Field(Field(Content, Char(10), 6), '=', 2)
JobElapsed = Field(Field(Content, Char(10), 7), '=', 2)
JobStatus = Field(Field(Field(Content, Char(10), , '=', 2), ' ', 1)
JobDesc = Field(Field(Field(Content, Char(10), , '(', 2), ')', 1)
**
Try it, it works.
regards,
Azens
Azens Chang
MetaEdge Corp.
You can try this function 'DSMakeJobReport'.
It generates a string describing the complete status of a valid attached job.
There are some sample codes I wrote in a routine to capture the start time, end time, elapsed time, status and status description for jobs.
**
JobHandle = DSAttachJob(JobName, DSJ.ERRNONE)
Content = DSMakeJobReport(JobHandle, 0, 'LF')
JobStart = Field(Field(Content, Char(10), 5), '=', 2)
JobEnd = Field(Field(Content, Char(10), 6), '=', 2)
JobElapsed = Field(Field(Content, Char(10), 7), '=', 2)
JobStatus = Field(Field(Field(Content, Char(10), , '=', 2), ' ', 1)
JobDesc = Field(Field(Field(Content, Char(10), , '(', 2), ')', 1)
**
Try it, it works.
regards,
Azens
Azens Chang
MetaEdge Corp.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 56
- Joined: Thu Feb 13, 2003 6:08 pm
- Location: USA
Here is the piece of code that I use hope it helps
vJobBatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
vJobName = rpt$[(Index(rpt$,"STATUS REPORT FOR JOB:",1)+22),Index(rpt
$,"Generated:",1)-(Index(rpt$,"STATUS REPORT FOR JOB:",1)+23)]
vTimeStamp = rpt$[Index(rpt$,"Generated:",1)+11, 19]
vStartTime = rpt$[Index(rpt$,"Job start time=",1)+15, 19]
vEndTime = rpt$[Index(rpt$,"Job end time=",1)+13, 19]
vJobStat = rpt$[Index(rpt$,"Job status=",1)+11, 2]
vJobBatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
vJobName = rpt$[(Index(rpt$,"STATUS REPORT FOR JOB:",1)+22),Index(rpt
$,"Generated:",1)-(Index(rpt$,"STATUS REPORT FOR JOB:",1)+23)]
vTimeStamp = rpt$[Index(rpt$,"Generated:",1)+11, 19]
vStartTime = rpt$[Index(rpt$,"Job start time=",1)+15, 19]
vEndTime = rpt$[Index(rpt$,"Job end time=",1)+13, 19]
vJobStat = rpt$[Index(rpt$,"Job status=",1)+11, 2]
-
- Participant
- Posts: 56
- Joined: Thu Feb 13, 2003 6:08 pm
- Location: USA
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
There's no direct CLI equivalent for DSMakeJobReport. The -jobinfo option comes closest, but will not provide all the information you seek. If you can identify the job number, then you could inspect the date/time modified of the job's status table (RT_STATUSxx) or log table (RT_LOGxx), which will be very close to the job finish time.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Not easily.
The metadata for these tables refers only to the key column (@ID), so that accessing any other column, collection or other structure within the table (remember that it's not first normal form) requires certain knowledge - and understanding - about the record layouts (which varies for different record types). This information is not in the public domain.
Similarly access from the operating system command prompt can not be achieved directly (they are database tables, after all). However, they are implemented as operating system objects, so you should be able to use something like attrib to determine the date/time modified (which was my suggestion).
Decoding job name to job number is done in the DS_JOBS table. Again this can only be indirectly be accessed from the operating system.
Also check out the options in dsjob for finding the most recent event in the job log, the timestamp in which should be the job finish time.
The metadata for these tables refers only to the key column (@ID), so that accessing any other column, collection or other structure within the table (remember that it's not first normal form) requires certain knowledge - and understanding - about the record layouts (which varies for different record types). This information is not in the public domain.
Similarly access from the operating system command prompt can not be achieved directly (they are database tables, after all). However, they are implemented as operating system objects, so you should be able to use something like attrib to determine the date/time modified (which was my suggestion).
Decoding job name to job number is done in the DS_JOBS table. Again this can only be indirectly be accessed from the operating system.
Also check out the options in dsjob for finding the most recent event in the job log, the timestamp in which should be the job finish time.