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

How to convert DATE datatype to TIMESTAMP datatype?


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

New User


Joined: 11 Aug 2005
Posts: 85
Location: England

PostPosted: Thu Sep 27, 2007 10:28 am
Reply with quote

Hi All,

I had one question, Can i convert the DATE datatype in DB2 to TIMESTAMP datatype, by making use of some function?
Early response would be appreciated.

Regards
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Sep 27, 2007 11:05 am
Reply with quote

leo_sangha,

This might help you -

publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0000860.htm
Back to top
View user's profile Send private message
mbr_raja

New User


Joined: 15 Nov 2004
Posts: 26
Location: Chennai, India

PostPosted: Fri Sep 28, 2007 1:04 pm
Reply with quote

You can try to use the function Timestamp to convert given date into timestamp format.

TIMESTAMP (START_DATE, START_TIME)
for ex: TIMESTAMP('2007-09-28',' ')

the output will be timestamp format as 2007-09-28-00.00.00.000000
Back to top
View user's profile Send private message
leo_sangha

New User


Joined: 11 Aug 2005
Posts: 85
Location: England

PostPosted: Mon Oct 01, 2007 9:51 am
Reply with quote

Hello Murmohk,

I tried TIMESTAMP_ISO function but i guess we might have previous version of DB2 installed, i am getting the below error:

DSNT408I SQLCODE = -440, ERROR: NO FUNCTION BY THE NAME TIMESTAMP_ISO HAVING COMPATIBLE ARGUMENTS WAS FOUND IN THE CURRENT PATH

below is the SQL i am using
SELECT * FROM TABLE
WHERE UPDATE_TIMESTAMP >
TIMESTAMP_ISO('2007-09-9');

Do you have any idea about this ?

mbr_raja


i tried your solution it is giving me below error:

SELECT * FROM TABLE
WHERE UPDATE_TIMESTAMP >
TIMESTAMP('2007-09-18','-00.00.00.000000');

DSNT408I SQLCODE = -180, ERROR: THE DATE, TIME, OR TIMESTAMP VALUE *N IS INVALID

Could you please share the SQL with me which you executed?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Oct 01, 2007 5:55 pm
Reply with quote

You could use
Code:
where update_timestamp > '2007-09-18-
00.00.00.000000'


or the slightly less efficient
Code:
where date(update_timestamp) > '2007-09-18'
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Sorting date into YYYYMMDD, and creat... DFSORT/ICETOOL 13
No new posts Sort card to know that creation date ... DFSORT/ICETOOL 10
No new posts Convert CSV to flat file. DFSORT/ICETOOL 6
No new posts convert arbitrary UTC to local (SYD) ... COBOL Programming 1
No new posts Help with SORT - I need to validate d... DFSORT/ICETOOL 11
Search our Forums:


Back to Top