i want to add hours to timestamp .

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
sanjay
Premium Member
Premium Member
Posts: 203
Joined: Fri Apr 23, 2004 2:22 am

i want to add hours to timestamp .

Post by sanjay »

Hi
i want to add hours to timestamp . is it possible in Parallel Extender 7.5

Sanjay
T42
Participant
Posts: 499
Joined: Thu Nov 11, 2004 6:45 pm

Post by T42 »

Yes.

:P
T42
Participant
Posts: 499
Joined: Thu Nov 11, 2004 6:45 pm

Post by T42 »

Code: Select all

TimeFromMidnightSeconds(((HoursFromTime([input time]) * 3600) + (MinutesFromTime([input time]) * 60) + SecondsFromTime([input time])) + [hours * 3600])
This will work for "Time" field. Have fun with the "Timestamp" version. :)
sanjay
Premium Member
Premium Member
Posts: 203
Joined: Fri Apr 23, 2004 2:22 am

adding hour to timestamp (Urgent Help Required)b

Post by sanjay »

i am finding difficult in adding hour to timestamp field for in Parallel extender . my

timestamp field : '2004-10-28 10:22:33' want add 10 hours to the field . can anyone help me . i want to do it in PX


sanjay












T42 wrote:

Code: Select all

TimeFromMidnightSeconds(((HoursFromTime([input time]) * 3600) + (MinutesFromTime([input time]) * 60) + SecondsFromTime([input time])) + [hours * 3600])
This will work for "Time" field. Have fun with the "Timestamp" version. :)
ahmediftikhar
Participant
Posts: 22
Joined: Thu Jul 29, 2004 8:10 am

Post by ahmediftikhar »

Lets say your input is DateIn = '2004-10-28 10:22:33'

Following are the stage variables used:

SDate : Field(DateIn," ",1)
STime : Field(DateIn," ",2)
SHours: 10
SAddTime: TimeFromMidnightSeconds(((HoursFromTime(STime) * 3600) + (MinutesFromTime(STime) * 60) + SecondsFromTime(STime)) + (SHours * 3600))


Output:

SDate : " " : SAddTime

Result : 2004-10-28 20:22:33

Its the same solution given by T42 in explanatory steps :wink:
Prashantoncyber
Participant
Posts: 108
Joined: Wed Jul 28, 2004 7:15 am

Post by Prashantoncyber »

How you going to increase the date if after adding the hours , date gets incremented?
sanjay
Premium Member
Premium Member
Posts: 203
Joined: Fri Apr 23, 2004 2:22 am

Regarding adding hourse to timestamp

Post by sanjay »

hi ahmediftikhar

thanks

but how the date will increase because u are just concatenating.


Sanjay
Prashantoncyber wrote:How you going to increase the date if after adding the hours , date gets incremented?
ahmediftikhar
Participant
Posts: 22
Joined: Thu Jul 29, 2004 8:10 am

Post by ahmediftikhar »

Its very simple add two more stage variable

SAddHours: HoursFromTime(STime) + SHours
SAddDate : If SAddHours > 23 Then DateFromDaysSince(Div(SAddHours,24),SDate) Else SDate

Output is SAddDate : " " : SAddTime

Hope this helps

Ahmed.
sanjay
Premium Member
Premium Member
Posts: 203
Joined: Fri Apr 23, 2004 2:22 am

Regarding adding hour to timestamp

Post by sanjay »

Thanks ahmed u have made my task simple

but one clarification required

regarding

SAddTime : TimeFromMidnightSeconds(((HoursFromTime(STime) * 3600) + (MinutesFromTime(STime) * 60) + SecondsFromTime(STime)) + (SHours * 3600))

above function

suppose time : 16:00:00

if u are adding 10 hrs will it make it 06:00:00
Regards
Sanjay



ahmediftikhar wrote:Its very simple add two more stage variable

SAddHours: HoursFromTime(STime) + SHours
SAddDate : If SAddHours > 23 Then DateFromDaysSince(Div(SAddHours,24),SDate) Else SDate

Output is SAddDate : " " : SAddTime

Hope this helps

Ahmed.
ahmediftikhar
Participant
Posts: 22
Joined: Thu Jul 29, 2004 8:10 am

Post by ahmediftikhar »

Test it out urself. It will make 02:00:00
Post Reply