How to get the fraction of seconds in the time hh:mm:ss-sss

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ravindrag
Participant
Posts: 40
Joined: Wed Dec 14, 2005 3:22 am

How to get the fraction of seconds in the time hh:mm:ss-sss

Post by ravindrag »

Please tell how to get the fraction of seconds part from the date format below:
YYYY-MM-DD HH:MM:SS.SSS

.SSS indicates fraction of seconds in the above formate.

Please confirm whether there is any function or any other solution to get the fraction of seconds part (SSS) in datastage.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Substring comes to mind. Also Field (unless that's not supported in a PX job?):

Code: Select all

Field(YourDate,".",2,1)
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Field() is supported in parallel Transformer stages.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sharathsj
Participant
Posts: 3
Joined: Tue Nov 21, 2006 1:11 am

Re: How to get the fraction of seconds in the time hh:mm:ss-

Post by sharathsj »

ravindrag wrote:Please tell how to get the fraction of seconds part from the date format below:
YYYY-MM-DD HH:MM:SS.SSS

.SSS indicates fraction of seconds in the above formate.

Please confirm whether there is any function or any other solution to get the fraction of seconds part (SSS) in datastage.
Hi all. The value SSS has to be extracted in the sequencer and has to be attached to the target file while writing. So how can this be encorporated. PLease suggest a solution.
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Re: How to get the fraction of seconds in the time hh:mm:ss-

Post by I_Server_Whale »

sharathsj wrote: Hi all. The value SSS has to be extracted in the sequencer and has to be attached to the target file while writing. So how can this be encorporated. PLease suggest a solution.
Welcome aboard ! :)

Extracted from where???? From a incoming record, filename? Need that information.

Also, I think you meant 'incorporated' and not 'encorporated'.

Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
sharathsj
Participant
Posts: 3
Joined: Tue Nov 21, 2006 1:11 am

Post by sharathsj »

Hi..
There is a job. When the job is run, the date+Time+Fraction of a sec need to be concatenated to the name of the file and then the file has to be created. This process should be done in the sequencer. This sequencer has 2 jobs and in both the jobs files have to be created as mentioned above.

From where it has to extracted is answered, i guess, above.
Sharath, Associate Consultant, Capgemini India, Bangalore.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

You also have microseconds_from_time() function.
You need to pass it as a parameter to a job for the file creation. The job where you select the value from, write it in to a file. Using ExecuteCommand Stage, read the file using cat filename command and use the commandOutput to pass it as a parameter to the next JobActivity stage.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Hi,

Declare a parameter called FileDate in your job which is writing to sequential file. Make sure you include the parameter in the output filename field of the sequential file stage, something like

Code: Select all

e:\XXXXX\YYYYYY\ZZZZZ\Name_Of_The_File#FileDate#
And then, create a job sequence with a job activity stage calling the above job. In the parameter derivation, enter:

Code: Select all

TRIM(OCONV(@DATE,'D4-YMD[4,2,2]'),"-","A"):TRIM(OCONV(@TIME,'MTS'),":","A") 
or

Code: Select all

TRIM(OCONV(@DATE,'D4-YMD[4,2,2]'):EREPLACE(OCONV(@TIME,'MTS'),':',''),"-","A") 
Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Whale - Arent you more intend to work in Server edtion :wink:
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Oh Gosh!!! The switch failed again.....I need to be focussing....Arrrgggghh. :oops: .No ICONV, OCONV in PX.

You can tell. Can't you? :wink: Yeah, I'm more of Server guy. Just getting my hands wet with Parallel.

Thanks kumar_s.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Yea but it should still work in a sequence job. Try it, if it doesnt, o bugger. Plus Whale's code wont give you the franction seconds part. Are you talking about current date and timestamp to be concatenated to the target file? I am still confused on that part.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Sequence jobs are Server jobs, using DS BASIC. No DS BASIC date functions give fractional seconds. You're going to need to use something from Unix to do this. I did a man on date and didn't see a switch to give fractional seconds. I suggest you add ".000".
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

System(12) gives milliseconds. You can also set $OPTIONS TIME.MILLISECONDS as a compiler directive.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply