trying to truncate the string

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
gayatri
Participant
Posts: 7
Joined: Tue Dec 12, 2006 11:08 am

trying to truncate the string

Post by gayatri »

Hi,

I am trying to truncate part of the string. This is the raw data.

1/1/2007 0:00:00

I only need date from this. How can i extract only the date.
I used Left function, not working. Is there any truncate function in datastage that I can use.

Thanks
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Welcome Aboard :P
Use the Field Function. Use DataStage help to see how it works.
For your problem, use this

Code: Select all

Field(in.Col, " ",1)
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gayatri
Participant
Posts: 7
Joined: Tue Dec 12, 2006 11:08 am

Post by gayatri »

DSguru2B wrote:Welcome Aboard :P
Use the Field Function. Use DataStage help to see how it works.
For your problem, use this

Code: Select all

Field(in.Col, " ",1)
I used this function. I am getting this error.

Field(in.Col, "0:00:00 ",1)

it returned

"1/1/2"

Please correct me if I am doing this wrong.
johnthomas
Participant
Posts: 56
Joined: Mon Oct 16, 2006 7:32 am

Post by johnthomas »

Try extracting using string function the date portion from timestamp , since leanth of the date portion varies depending whether its a 1 digit day or month
JT
johnthomas
Participant
Posts: 56
Joined: Mon Oct 16, 2006 7:32 am

Post by johnthomas »

try Field(in.Col, " ",1) in place of Field(in.Col, "0:00:00 ",1) as suggested by dsguru
JT
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

As mentioned above use

Code: Select all

Field(in.Col, " ",1)
You are using

Code: Select all

Field(in.Col, "0:00:00 ",1)
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

In the expression that i provided earlier, "in.Col" is your input column. You need to replace that with your inputlink.columnname.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gayatri
Participant
Posts: 7
Joined: Tue Dec 12, 2006 11:08 am

Post by gayatri »

DSguru2B wrote:In the expression that i provided earlier, "in.Col" is your input column. You need to replace that with your inputlink.columnname. ...
Thanks so much function worked
but I am getting another error now

SQLSTATE=22008, DBMS.CODE=0
[DataStage][SQL Client][ODBC][Oracle][ODBC]Datetime field overflow.

Any suggestions.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Check this post
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

If you are using database stage, you can use TO_DATE() to convert it into the required date format.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply