IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Can substring be used for var declared as TIMESTAMP


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sriram K

New User


Joined: 17 Feb 2009
Posts: 32
Location: Bangalore

PostPosted: Sat Jun 13, 2009 1:33 pm
Reply with quote

Can substring be used for a table variable declared as TIMESTAMP.

I tried the below query

* COLA is declared as TIMESTMAP *

Select SUBSTR( COLA, 1, 10)
From TABLEA
...
..


I got sqlcode -171. Can anyone suggest on this.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Jun 13, 2009 3:35 pm
Reply with quote

Suggest you cast the timestamp column with the scalar function CHAR
Back to top
View user's profile Send private message
Raghu navaikulam

Active User


Joined: 27 Sep 2008
Posts: 193
Location: chennai

PostPosted: Tue Jun 16, 2009 4:03 pm
Reply with quote

Hi

As Dick suggested, you can use the CHAR function to convert Packed Decimal Timestamp to Character format and then apply SUBSTR function.

Eg. SELECT SUBSTR(CHAR(COLA), 1,10)) FROM TABLEA;

Regards
Raghu
Back to top
View user's profile Send private message
Sriram K

New User


Joined: 17 Feb 2009
Posts: 32
Location: Bangalore

PostPosted: Wed Jun 17, 2009 8:19 pm
Reply with quote

It worked.

Thanks.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Duplicate transid's declared using CEDA CICS 3
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
Search our Forums:

Back to Top