date time arithmatic in 8.1 parallel

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
hsahay
Premium Member
Premium Member
Posts: 175
Joined: Wed Mar 21, 2007 9:35 am

date time arithmatic in 8.1 parallel

Post by hsahay »

Hi

I need some help with date time arithmetic.

I have read a lot of threads and read all about the various date and time functions but have not been able to figure out how to achieve what i need.

My table has the following two fields -

start_date
start_time

The initial date and time values will be passed to the job as job parameters -

for example

07/01/2013 and
00:00:00

Then with each incoming row i need the time part to increment by 1 second and obviously when the seconds reaches 60, it should reset to 0 and minute should increment by 1 and when minutes reach 60, it should reset to 0 and hour should increment by 1....hour reaches 24 it should reset to 00 and the date should increment by 1 ....
(don't ask me why. It is a weird requirement)

All the nice functions like TimestampOffsetBySeconds etc are in 8.5 ...we are still using 8.1 ...can't figure out how to do this.

Please help.
vishal
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm not familiar with which functions are new to 8.5 and which ones are available in 8.1 that would be useful in this situation. However, it seems to me you should be able to increment the date and time separately. Meaning, increment the seconds and when you hit midnight add one day to the date. There should be functions in 8.1 to handle time or seconds since midnight.

Worst case you could go old school, knowing that 86400 seconds is a day you increment your seconds count, converting to time until you hit that number where you reset to zero and bump the date by a day.
-craig

"You can never have too many knives" -- Logan Nine Fingers
hsahay
Premium Member
Premium Member
Posts: 175
Joined: Wed Mar 21, 2007 9:35 am

Post by hsahay »

Thanks Craig.

I looked and looked and looked and finally found these two that i could use in 8.1

8.5 has a much more comprehensive set available.

TimestampFromDateTime(datePart, timePart)
and
TimestampFromSecondsSince(1, timestampValue)
--increments timestamp by 1 second.

I Defined DatePart = '2013-07-01' and TimePart = '00:00:00'. It did an implicit conversion from string to date / time and everything was okay after that.

After the increment by 1 sec, i did left(timestampValue,10) to get the date part and right(timestampValue,8) to get the time part.
vishal
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

hsahay wrote:left(timestampValue, 10) to get the date part and right(timestampValue ,8) (That smiley is supposed to be the number 8. Don't know why i am getting a smiley there) to get the time part.
Because an 8 followed by a right paren is the board code for a smiley. When you don't want them you enable the "Disable smilies in this post" option. I went back and did that for you in your post.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply