Page 1 of 1

Type conversion not recognized

Posted: Sat Mar 13, 2010 5:48 pm
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.

Posted: Sat Mar 13, 2010 10:58 pm
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?

Posted: Sun Mar 14, 2010 7:35 pm
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.

Posted: Sun Mar 14, 2010 8:52 pm
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)

Posted: Mon Mar 15, 2010 5:34 am
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.

Posted: Mon Mar 15, 2010 9:01 am
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.