Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-14731

EXTRACT(HOUR ....) gives incorect value when hour > 23

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Not a Bug
    • 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
    • N/A
    • Temporal Types
    • None

    Description

      Using extract to get number of hours from a time_diff function produces incorrect results when number of hours is greater than 23.

      Here's the details...

      SET @prev_ts = '2017-11-30 11:00:00';
      SELECT NOW()
          , TIMEDIFF(NOW(),@prev_ts)
          , TIME_FORMAT(TIMEDIFF(NOW(),@prev_ts), '%H') AS 'diff TIME_FORMAT'
          , EXTRACT(HOUR FROM  TIMEDIFF(NOW(),@prev_ts)) AS 'diff EXTRACT '
      ;
      /*
      NOW()                          TIMEDIFF(NOW(),@prev_ts)  diff TIME_FORMAT  diff EXTRACT   
      2017-12-15 20:58:25   369:58:25                                369               9              
      */
      

      SET @prev_ts = '2017-12-14 22:00:00';
      SELECT NOW()
          , TIMEDIFF(NOW(),@prev_ts)
          , TIME_FORMAT(TIMEDIFF(NOW(),@prev_ts), '%H') AS 'diff TIME_FORMAT'
          , EXTRACT(HOUR FROM  TIMEDIFF(NOW(),@prev_ts)) AS 'diff EXTRACT '
      ;
      /*
      NOW()                          TIMEDIFF(NOW(),@prev_ts)  diff TIME_FORMAT  diff EXTRACT   
      2017-12-15 21:19:32   23:19:32                                  23                             23             
      */
      

      Attachments

        Activity

          People

            bar Alexander Barkov
            thebreadguru MIke Thibodeau
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.