Oracle uses ROUND and EXTRACT for date operations

Source: Internet
Author: User
Oracle uses ROUND and EXTRACT for date operations

Oracle uses ROUND and EXTRACT for date operations

Oracle uses ROUND and EXTRACT for date operations:

ROUND (d, [fmt]): returns a rounding date value in the fmt Format.

D is the date, fmt is the format model, and cannot be the hour, minute, and second. The default value is DDD, that is, one day of the month.

  • If fmt is "YEAR", it is rounded to January 1 of a YEAR, that is, the first half of the YEAR, and the last half of the YEAR is used as the next YEAR.
  • If fmt is "MONTH", it is rounded to the day of a MONTH, that is, the first half of the MONTH, and the second half of the MONTH as the next MONTH.
  • If fmt is "DDD", that is, a day in the month, the day closest to the day, the first half of the day will be taken away, and the next half day will be taken as the next day.
  • If fmt is "DAY", it is rounded to Sunday of the last week, that is, the first half of the week is taken away, and the second half is used as the next week.
  • EXTRACT (fmt FROM d): EXTRACT a specific part of a date.

    Fmt is: YEAR, MONTH, DAY, HOUR, SECOND. YEAR, MONTH, and DAY can be of the DATA type or TIMESTAMP type. However, HOUR, MINUTE, and SECOND must be of the TIMESTAMP type.

    For more information about Oracle, see the Oracle topic page? Tid = 12

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.