Type conversion not recognized

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Murali4u
Participant
Posts: 37
Joined: Sun Feb 21, 2010 12:27 pm

Type conversion not recognized

Post by Murali4u »

Hi when i try to convert a string to date from a transformer stage it shows the derivation as red in color even when i used the same format as IBM indicated StringToDate(string,Format). Can any one tell the solution.
Rockzz Tech
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

StringToDate() is a PX function so no good in a Server job. For that you'll probably need the IConv/OConv tag team but that can depend on what you mean by "date". What's your target?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Murali4u
Participant
Posts: 37
Joined: Sun Feb 21, 2010 12:27 pm

Post by Murali4u »

[quote="chulett"][i]StringToDate()[/i] is a [b]PX[/b] function so no good in a Server job. For that you'll probably need the IConv/OConv tag team but that can depend on what you mean by "date". What's your target? ...[/quote]

Craig,
I want to extract any format of date such as (timestamp, sybase datatime) to a date(yyyy-mm-dd) I tried to extract the first top ten position of the value of that column but it results in string. So to adjust it into the date. i need the conversion. Or if any other solution please let me know.
Rockzz Tech
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Everything in server jobs is a string. The fact that you can use these strings to load into databases is a bonus - but that's precisely what you are doing with manually-entered SQL after all.

Thus the easiest way to get a date from a timestamp is to extract the first 10 characters.

Code: Select all

Left(InLink.TheTimestamp, 10)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Murali4u
Participant
Posts: 37
Joined: Sun Feb 21, 2010 12:27 pm

Post by Murali4u »

[quote="ray.wurlod"]Everything in server jobs is a string. The fact that you can use these strings to load into databases is a bonus - but that's precisely what you are doing with manually-entered SQL after all.

Thus ...[/quote]

Just for an effective straight forward question:

How to convert the string "1999-01-01 10:30:50" to Date "1999-01-01" in server job.

I used Oconv(Iconv("1999-01-01 10:30:50"),"DMYD"),"D-YMD"). And the source is of String type and target is Date.
Rockzz Tech
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And you got an 'effective straight forward' answer in Ray's post. :?

OK... first you need to ensure that you really need something in an external YYYY-MM-DD format for your date target. And since your source is already in that format (it just has some extra bits) if that's really what you need then there's no need to "convert" anything. Simply take the first 10 characters (or the first 'field') using whatever technique floats your boat.

:idea: If you are going to quote people and otherwise use the tags the forum software supports, you cannot check/enable the 'Disable BBCode in this post' option. FYI.
-craig

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