TIme calulation
Moderators: chulett, rschirm, roy
TIme calulation
When I launch a job, i save the startdate and starttime in order
to write them later in a file.
I use the DSJobStartDate and DSJobStartTime functions (I can't find them
in the documentation !!!, maybe can you give me any link).
What I want to do is to make time calculation
If the current time is 10:25:29, i want to have in my result 10:25:29 - 5 seconds for example, so 10:29:24
Mydelayedtime = DSJobStartTime - 5 seconds
is there any functions to make this easily...
Thank you for your response...
to write them later in a file.
I use the DSJobStartDate and DSJobStartTime functions (I can't find them
in the documentation !!!, maybe can you give me any link).
What I want to do is to make time calculation
If the current time is 10:25:29, i want to have in my result 10:25:29 - 5 seconds for example, so 10:29:24
Mydelayedtime = DSJobStartTime - 5 seconds
is there any functions to make this easily...
Thank you for your response...
Alternatively, You can convert the time into seconds.
For eg you have Time in HH:MI:SS format
In Seconds = HH*60*60 + MI*60 +SS
and then substract 5 from Time in Seconds and then again convert it to the standard format you need.
I would not say that this approach is good but it is an alternative if u don't want to use Iconv/OconV
For eg you have Time in HH:MI:SS format
In Seconds = HH*60*60 + MI*60 +SS
and then substract 5 from Time in Seconds and then again convert it to the standard format you need.
I would not say that this approach is good but it is an alternative if u don't want to use Iconv/OconV
----------------
Rgds,
Anupam
----------------
The future is not something we enter. The future is something we create.
Rgds,
Anupam
----------------
The future is not something we enter. The future is something we create.
if you
X = iconv("12:00:01am", "MTHS")
then X should be 1. Internal version of time, I think, is seconds past midnight. The help on iconv() and MT conversion is very good. You can leave off the "am" and "pm". You can deal with 24 clocks whatever you need. Anything less than a second you should deal with yourself. My suggestion is leave the metadata as a varchar and iconv only when you need to add or subtract time.
X = iconv("12:00:01am", "MTHS")
then X should be 1. Internal version of time, I think, is seconds past midnight. The help on iconv() and MT conversion is very good. You can leave off the "am" and "pm". You can deal with 24 clocks whatever you need. Anything less than a second you should deal with yourself. My suggestion is leave the metadata as a varchar and iconv only when you need to add or subtract time.
Mamu Kim
-
- 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:
TIMEDATE() function returns the current date and time in a non-standard "timestamp-like" format.
The documented way to retrieve the job start is to use DSGetJobInfo with an InfoType argument of DSJ.JOBSTARTTIMESTAMP. The time component is in external format; you can retrieve it with substring or Field() function or the DataStage macro DSJobStartTime, then apply an Iconv() function to get it into internal format.
Kim's recollection is correct, in that internal format is seconds since midnight.
Therefore a suitable piece of code is the following.
If you need an expression it would be less efficient, because you have to evaluate the macro more than once. For example:
but you could always create a stage variable (say svJobStartTime, initialized as the macro DSJobStartTime, and derived as not changing its value), so that the macro is only evaluated once for the entire job:
Finally, use Oconv() to get the time into a human-readable format, if that is desired.
The documented way to retrieve the job start is to use DSGetJobInfo with an InfoType argument of DSJ.JOBSTARTTIMESTAMP. The time component is in external format; you can retrieve it with substring or Field() function or the DataStage macro DSJobStartTime, then apply an Iconv() function to get it into internal format.
Kim's recollection is correct, in that internal format is seconds since midnight.
Therefore a suitable piece of code is the following.
Code: Select all
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.G
$ENDIF
JobStartTime = Iconv(DSJobStartTime, "MT")
FiveSecondsEarlier = JobStartTime - 5
If FiveSecondsEarlier < 0 Then FiveSecondsEarlier += 86400
Code: Select all
If DSJobStartTime < "00:00:05" Then DSJobStartTime + 86395 Else DSJobStartTime - 5
Code: Select all
If svJobStartTime < "00:00:05" Then svJobStartTime + 86395 Else svJobStartTime - 5
Code: Select all
Oconv(FiveSecondsEarlier, "MTS:")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.