How to find the max of a Timestamp field

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
saini
Participant
Posts: 18
Joined: Sat Jan 13, 2007 12:01 am

How to find the max of a Timestamp field

Post by saini »

Hi

I have a requirement to find the max of a column. Its datatype is Timestamp.

I am trying to get the max of that column through aggregator Stage.


I get the following error:
Aggregator_94: Error when checking operator: When binding input interface field "ADJUST_DT" to field "ADJUST_DT": No default type conversion from type "timestamp" to type "dfloat". [api/interface_rep.C:803]

Please suggest

Thanks!!!
crouse
Charter Member
Charter Member
Posts: 204
Joined: Sun Oct 05, 2003 12:59 pm
Contact:

Post by crouse »

Use the TimetFromTimestamp function to convert the timestamp to a number, then run through agg to get max, then use TimestampFromTimet to convert it back to the timestamp. Need to mess with conversion using DecimalToDfloat, I think, in order avoid a warning at runtime, since the agg expects the column to be dfloat. Or just live with the warning.

-Craig
Craig Rouse
Griffin Resouces, Inc
www.griffinresources.com
saini
Participant
Posts: 18
Joined: Sat Jan 13, 2007 12:01 am

Post by saini »

Is this function in the Transformer Stage as I am unable to find it
crouse wrote:Use the TimetFromTimestamp function to convert the timestamp to a number, then run through agg to get max, then use TimestampFromTimet to convert it back to the timestamp. Need to mess with conversion using DecimalToDfloat, I think, in order avoid a warning at runtime, since the agg expects the column to be dfloat. Or just live with the warning.

-Craig
pneumalin
Premium Member
Premium Member
Posts: 125
Joined: Sat May 07, 2005 6:32 am

Post by pneumalin »

Yes, it's in Transformer Stage. But ensure you are using PX Transformer, Basic Transformer doesn't have this function.
blitz76
Participant
Posts: 5
Joined: Fri Jul 11, 2008 12:31 pm

Post by blitz76 »

Hi
I have been having issues with these functions for one date that we use to depect infinity.
This date is 2199-02-03 00:00:00 (YYYY-MM-DD).

Here is the issue.
After the aggregation, when i try to convert back the value, it converts to some other date.

TimetFromTimestamp('2199-02-03 00:00:00') gives -1360500992
And TimestampFromTimet(-1360500992) gives 1926-11-22 11:03:28 !!!!!!!!!!!!!


Did anybody face this issue before?.Would apprciate any inputs.

Regs
Ameet
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

Try without converting timestamp to time format. In aggregator, you can add a subproperty "preserve type" to TRUE.
Kandy
_________________
Try and Try again…You will succeed atlast!!
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I suspect you're using Integer as the data type and getting overflow. A date in the future ought not to generate a negative timet. Try using dfloat as the data type.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
bikan
Premium Member
Premium Member
Posts: 128
Joined: Thu Jun 08, 2006 5:27 am

Post by bikan »

Hi Gurus,

Sorry for hacking the thread, but I thought it would be easier for everyone to relate to my problem.

I also have to find MAX of a timestamp variable. I used timetfromtimestamp function, as suggested, to calculate the MAX value in aggregator.

My input timestamp field contains microseconds.

When I convert the output of aggregator to timestamp using timestamptotimet function, the microseconds data is lost.

Is there any other way to find MAX of timestamp variable and retain
microsecond data?

Thank you in advance.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

bikan wrote:Hi Gurus,

Sorry for hacking the thread, but I thought it would be easier for everyone to relate to my problem.

I also have to find MAX of a timestamp variable. I used timetfromtimestamp function, as suggested, to calculate the MAX value in aggregator.

My input timestamp field contains microseconds.

When I convert the output of aggregator to timestamp using timestamptotimet function, the microseconds data is lost.

Is there any other way to find MAX of timestamp variable and retain
microsecond data?

Thank you in advance.
instead to hacking this thread if you would have used the reply given by kandyshandy in this post itself. :wink: you can use the sub property preserve type and setting it to yes will give you the desired output.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
Post Reply