rounding milliseconds to seconds in db2

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JayaramN
    New Member
    • Nov 2012
    • 4

    rounding milliseconds to seconds in db2

    How to convert the timestamp to nearest seconds.
    example i am having date value as 2012-11-28 13:03:18.981
    and it needs to be rounded to 2012-11-28 13:03:19 in DB2 select query
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You can use the Round function.

    Comment

    • JayaramN
      New Member
      • Nov 2012
      • 4

      #3
      I tried the below query for rounding the timestamp:
      SELECT ROUND_TIMESTAMP ('2008-10-16-14.46.22.121222 ','MI')
      FROM SYSIBM.SYSDUMMY 1

      but it is not working i am getting the below error message:
      SELECT ROUND_TIMESTAMP ('2008-10-16-14.46.22.121222 ','MI') FROM SYSIBM.SYSDUMMY 1
      SQL0440N No authorized routine named "ROUND_TIMESTAM P" of type "FUNCTION"
      having compatible arguments was found. SQLSTATE=42884

      SQL0440N No authorized routine named "ROUND_TIMESTAM P" of type "FUNCTION " having compatible arguments was found.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        I don't know where you got ROUND_TIMESTAMP from because that's not what I said. I said ROUND.

        Comment

        • Anas Mosaad
          New Member
          • Jan 2013
          • 185

          #5
          Hi Rabbit,
          ROUND_TIMESTAMP does exist in 9.7 & 10.1 LUW.

          Comment

          Working...