If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > trunc_timestamp missing

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-05-07, 10:48
sueamus sueamus is offline
Registered User
 
Join Date: Apr 2007
Posts: 26
trunc_timestamp missing

Hi all,
I have sql that requires the function trunc_timestamp. I am using db2 v7.1 on a windows platform.(I still use this version coz our client uses the same).This function is not in v7, is it possible to create it(so that its user defined), and how do i do that? I was also advised to move zeroes to the portion of the timestamp that would have been truncated for both comparision fields, and then do a straight compare of the timestamp(I do not know how to do this. Any idea on how to use this approach).
Thank you in advance.
Reply With Quote
  #2 (permalink)  
Old 08-06-07, 04:47
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
simply subtract the parts of the timestamp you want to truncate.
eg:
CURRENT TIMESTAMP - MICROSECONDS(CURRENT TIMESTAMP) MICROSECONDS
truncates the microsecondpart,
CURRENT TIMESTAMP - MICROSECONDS(CURRENT TIMESTAMP) MICROSECONDS - SECONDS(CURRENT TIMESTAMP) SECONDS
truncates the seconds and so on.

there shouldn't be a problem to create a SQL scalar function that returns the truncated value
Reply With Quote
  #3 (permalink)  
Old 08-06-07, 14:45
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
As I said in the other forum/newsgroup: DB2 doesn't have a TRUNC_TIMESTAMP function (not in V7, V8, or V9). So you should tell us what this function is supposed to do.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 08-07-07, 01:46
sueamus sueamus is offline
Registered User
 
Join Date: Apr 2007
Posts: 26
Thanks Umayer, thats what i wanted to do and it worked perfectly.Trunc_timestamp does the same just that its only available for z/os users.
Reply With Quote
  #5 (permalink)  
Old 08-07-07, 04:01
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
@ stolze

TRUNC_TIMESTAMP was introduced in Version 7 of DB2 for z/OS

have a look at:
http://publib.boulder.ibm.com/cgi-bi...E=&PICTORIAL=N
Reply With Quote
  #6 (permalink)  
Old 08-07-07, 11:45
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Ah! Typical problem if the OP doesn't name the system he is referring to.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On