Page 1 of 2

change current date + different second for each row

Posted: Sun Jan 20, 2013 6:37 am
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

Posted: Sun Jan 20, 2013 7:36 am
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.

Posted: Sun Jan 20, 2013 11:56 pm
by times29
Don't like TimeOffsetBySeconds(DSJobStartTimestamp,1) in transformer

Posted: Mon Jan 21, 2013 12:26 am
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".

Posted: Mon Jan 21, 2013 5:57 am
by ArndW
My mistake, instead of "1" use "@INROWNUM" - sorry.

Re: change current date + different second for each row

Posted: Mon Jan 21, 2013 2:42 pm
by SURA
Irrespective of the real writing time, do you need to increase 1 sec for each row?

Posted: Mon Jan 21, 2013 5:58 pm
by times29
Yes

Posted: Mon Jan 21, 2013 7:41 pm
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.

Posted: Wed Jan 23, 2013 2:39 am
by times29
Transformer didn't likeTimeOffsetBySeconds(DSJobStartTimestamp,@INROWNUM) i don't see
function TimeOffsetBySeconds under date&time can that be issue

Posted: Wed Jan 23, 2013 2:56 am
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.

Posted: Wed Jan 23, 2013 8:03 am
by chulett
TimeOffsetBySeconds() is perfectly valid. What exact version are you on?

Posted: Wed Jan 30, 2013 6:07 am
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")

Posted: Wed Jan 30, 2013 8:43 am
by srinivas.nettalam
Since the job runs in parallel @INROWNUM can have same rownumber on each node.Probably this is the reason.Not sure.

Posted: Wed Jan 30, 2013 7:54 pm
by times29
:shock: any idea what can i do to make it unique

Posted: Thu Jan 31, 2013 12:59 am
by ray.wurlod
Run on a single node, or generate numbers that are unique across the domain. Search DSXchange for techniques and formulae.