The ORACLE time field is set to year, month, day, and quarter.

Source: Internet
Author: User

Select year, month, day, and quarter for the ORACLE time field -- get year, month, and quarter select to_char (date, 'yyyymmdd') DATE_ID, to_char (date, 'yyyy ') | 'Year' | to_char (date, 'mm') | 'month' | to_char (date, 'dd') | 'day' DATE_NAME, to_char (date, 'yyyymm') MONTH_ID, to_char (date, 'yyyy') | 'Year' | to_char (date, 'mm') | 'month' MONTH_NAME, 'q' | to_char (date, 'q. yyyy ') QUARTERID, to_char (date, 'yyyy') | 'Year' | to_char (date, 'q') | 'quarter 'quarterid_name, to_char (date, 'yyyy') YEAR_ID, to_char (date, 'yyyy') | 'Year' YEAR_NAME from (select to_date ('2017-01-01 ', 'yyyy-mm-dd ') + (rownum-1) date from user_objects where rownum <367 and to_date ('2017-01-01 ', 'yyyy-mm-dd') + (rownum-1) <to_date ('1970-01-01 ', 'yyyy-mm-dd'); -- Obtain the ing between the quarter and the month. select distinct to_char (date, 'q') quarter, to_char (to_date ('1970-01-01 ', 'yyyy-mm-dd') + (rownum-1), 'yyymmm') date from (select to_date ('1970-01 ', 'yyyy-mm') + (rownum-1) date from user_objects where rownum <367 and to_date ('2017-01-01 ', 'yyyy-mm-dd') + (rownum-1) <to_date ('1970-01-01 ', 'yyyy-mm-dd'); -- select to_char (to_date ('1970-01-01 ', 'yyyy-mm-dd') + (rownum-1), 'yyyy-mm-dd') date from user_objects where rownum <367 and to_date ('2017-01-01 ', 'yyyy-mm-dd') + (rownum-1) <to_date ('2017-01-01 ', 'yyyy-mm-dd'); summary: to_char (sysdate, 'q ') season to_char (sysdate, 'yyyy') year to_char (sysdate, 'mm') month to_char (sysdate, 'dd') day to_char (sysdate, 'D ') DAY of the week to_char (sysdate, 'day') DAY of the week to_char (sysdate, 'ddd ') other method in the year: select extract (month from query_cxrq) from app_queryextract (year from query_cxrq) year extract (month from query_cxrq) month extract (day from query_cxrq) day -- convert the date format variable with time to the date format string method: 1. datetime. tostring ("yyyy. MM. dd ") 2. formatdatetime (datetime," yyyy. MM. dd ") 3. convert. todatetime (str ). tow.datestring ()

Related Article

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.