Diff between two dates in Datastage

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
srn2006
Participant
Posts: 3
Joined: Fri Feb 01, 2008 5:05 pm

Diff between two dates in Datastage

Post by srn2006 »

How to calculate the difference between two dates in Transformer stage in Datastage? Basically, I want to find the equivalent function for SQL Server "Datediff" in Datastage. Could any one help me please?

Thanks,
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Welcome! :D

Dates need to be converted to 'internal' format first, then those two dates can simply be subtracted to get the number of days between them. Is that the unit of difference you are interested in - # of days?

The IConv function will do the conversion for you, basically:

Code: Select all

IConv(YourDate,"D-YMD")
Where the information between the two quotes is the proper date mask for your incoming date. Adjust that to match your data.
-craig

"You can never have too many knives" -- Logan Nine Fingers
SHARAD123
Premium Member
Premium Member
Posts: 54
Joined: Wed Jan 09, 2008 12:05 am

Post by SHARAD123 »

The date gets converted to the datastage format, so that u may get the output in numeric format rather than as a date.

SO u can use either iconv or oconv functions depending on your needs.
Iconv- converts to the local datastage format i.e a number
OConv- converts to the date format

jus check out the help for the syntax and for the format.
222102
SHARAD123
Premium Member
Premium Member
Posts: 54
Joined: Wed Jan 09, 2008 12:05 am

Post by SHARAD123 »

The date gets converted to the datastage format, so that u may get the output in numeric format rather than as a date.

SO u can use either iconv or oconv functions depending on your needs.
Iconv- converts to the local datastage format i.e a number
OConv- converts to the date format

jus check out the help for the syntax and for the format.
222102
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There's an obvious problem with SHARAD23's answer, and it is that U did not ask the question. It was asked by srn2006.

In English, the second person personal pronoun is spelled "you".
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