change current date + different second for each row

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

times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

change current date + different second for each row

Post by times29 »

Hi,
Right now i am using Currenttimestamp() in transformer for date i need to change that to current date + different second for each row, stating at 00:00:00

example: 500 records created, TimeStamp content would be :
2012-01-15 00:00:00
2012-01-15 00:00:01
2012-01-15 00:00:02
2012-01-15 00:00:03
....
2012-01-15 00:08:20

who can i modify Currenttimestamp() to do that.

Thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Use "DSJobStartTimestamp", which remains the same for each row.
Derive the new timestamp with the formula

Code: Select all

TimeOffsetBySeconds(DSJobStartTimestamp,1)
Note that if the value has to be unique then, if you run on more than one node, you will have to adjust the algorithm.
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

Don't like TimeOffsetBySeconds(DSJobStartTimestamp,1) in transformer
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You probably don't like CurrentTimestamp() either, because it returns the current timestamp (that is, "now") whether or not another record is being processed.

I have some DataStage jobs processing over a quarter of a million rows per second on a two-node configuration. "Now" will be the same for each quarter of a million rows, with "second" as the granularity of the current timestamp.

Even setting the granularity to microseconds isn't going to help; "now" will be the same for more than one record. And that assumes that the underlying operating system can deliver quanta as short as 0.000001 second. Most cannot.

Arnd's response was, to me, perfectly sensible. If you don't like that, you're going to have to write your own function, and reinvent the meaning of "now".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

My mistake, instead of "1" use "@INROWNUM" - sorry.
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: change current date + different second for each row

Post by SURA »

Irrespective of the real writing time, do you need to increase 1 sec for each row?
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

Yes
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Then use Arnd's solution. Job start timestamp + @INROWNUM seconds. It will give you exactly what you've specified whether or not you happen to like it.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

Transformer didn't likeTimeOffsetBySeconds(DSJobStartTimestamp,@INROWNUM) i don't see
function TimeOffsetBySeconds under date&time can that be issue
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Look for similarly-named functions, maybe TimestampSinceFromSeconds(). We often post without access to the software; at the moment I'm in a hotel room.
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 »

TimeOffsetBySeconds() is perfectly valid. What exact version are you on?
-craig

"You can never have too many knives" -- Logan Nine Fingers
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

Below logic gives me results like below so in some cases i am getting same timestamp and some cases its unique.


"01/29/2013 21:51:20",
"01/29/2013 21:51:21"
"01/29/2013 21:51:22",
"01/29/2013 21:51:20",

TimestampToString(TimestampFromSecondsSince(@INROWNUM,DSJobStartTimestamp),"%mm/%dd/%yyyy %hh:%nn:%ss")
srinivas.nettalam
Participant
Posts: 134
Joined: Tue Jun 15, 2010 2:10 am
Location: Bangalore

Post by srinivas.nettalam »

Since the job runs in parallel @INROWNUM can have same rownumber on each node.Probably this is the reason.Not sure.
N.Srinivas
India.
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

:shock: any idea what can i do to make it unique
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Run on a single node, or generate numbers that are unique across the domain. Search DSXchange for techniques and formulae.
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