Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2007
    Posts
    26

    Unanswered: 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.

  2. #2
    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

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  4. #4
    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.

  5. #5
    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

  6. #6
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •