Finding Max of date

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
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Finding Max of date

Post by kumar_s »

Hi,
Is there any issue to find maximum of date.
mine is simple flow. input has data with date type feild. i just need find the max of the date based up on a grouping col. Iam getting the follwing error

Code: Select all

Aggregator_1: Error when checking operator: When binding input interface field "doj" to field "doj": No default type conversion from type "date" to type "dfloat"
Here "doj" id the name of the date field. it seems it is implictly converting from date to dfloat. i just grouped based on a column and found Maximum Value Output Column of this "doj" and nothing else. Output is also in date format.

Should i have to do anything more than this for date type or it happens for all?!?!?!?.......

regards
kumar
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

I just tried this getting similar error :(

From the error, it looks like internally DS aggr stage converts the columns to Dfloat before doing any Max/Min/Sum.

I tried adding to modify stage to convert Date to Int or float, but this is not permitted in modify stage.

One more try: converting the Date to integer using IConv of basic transformer and then doing min max :idea:

let see!!!
Regards,
S. Kirtikumar.
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
Try using a character oriented data type.
worst case scenario convert the date to numeric format of yyyymmdd
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi,
yes we tried every thing else, Iconv and Oconv works.
But we faced sluggish response of server due to Basic Transformer usage. Resulted in restrating server :cry:
Tried with StringToDecimal and then back to date. But unfortunately i faced a error which carries a native datatype of decimal all along to way.
We also had a thread reg this issue in this forum.
Atlast Tring with varchar oriented conversion, mmmm... WORKING. Feeling bad to carry two transformer on both side of Aggregator :cry:

regards
kumar
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

hi,

when i tried with char or varchar oriented method, i faced an issue which return only the year part.
But the way in which senthil proceeded, no probs........
works good :lol:

regards
deepak
tusharzade
Participant
Posts: 13
Joined: Wed Dec 15, 2004 2:19 am

Finding Max of date

Post by tusharzade »

Hi,

One approach is to Convert your date in the Integer format means if yor date is "yyyy-mm-dd" then convert it into "yyyymmdd" which is the integer and then use the max/min function. You can not aggregate on Date column as Aggregator stage converts into default dfloat before doing any aggregation.

Regards,
Tushar
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Re: Finding Max of date

Post by kumar_s »

Hi,
may i know how to convert to integer, is it through datetostring..... or any methond available.........

regards
kumar
Hi,

One approach is to Convert your date in the Integer format means if yor date is "yyyy-mm-dd" then convert it into "yyyymmdd" which is the integer and then use the max/min function. You can not aggregate on Date column as Aggregator stage converts into default dfloat before doing any aggregation.

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

Post by ray.wurlod »

Once you've removed the delimiter characters from the string, you can use the AsInteger() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi,
I felt string in such case can e implicitly converted to integer, am i right :roll:

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

Post by ray.wurlod »

Not in parallel jobs. That's why the AsInteger() function exists.
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 »

I don't think anything implicitly converts in parallel jobs. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Things that are "promotable", for example int8 to int16 or int32, can convert implicitly in parallel jobs. Otherwise the conversion must be performed explicitly. There is a table explaining this in the Parallel Job Developer's Guide, from memory in the chapter on the Modify stage.
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