Oracle takes week, month, quarter, and year start and end times

Source: Internet
Author: User

 1 Start time and end time of the fetch week
    • The start time of the pick-up week. Start with Monday.

Sql>select TRUNC (to_date (' 2013-11-25 10:31:11 ', ' yyyy-mm-dd HH24:MI:SS '), ' D ') + 1 ASA from DUAL;

A

-----------

2013/11/25

    • The end time of the fetch week. Ended in Sunday

Sql>select TRUNC (to_date (' 2013-11-25 10:31:11 ', ' yyyy-mm-dd HH24:MI:SS '), ' D ') + 7 ASA from DUAL;

A

-----------

2013/12/1

2 Start time and end time of the month are taken
    • The start time of the month is taken

Sql>select TRUNC (to_date (' 2013-11-25 10:31:11 ', ' yyyy-mm-dd HH24:MI:SS '), ' MM ') as Afrom DUAL;

A

-----------

2013/11/1

    • The end time of the month is taken

Sql>select Last_day (to_date (' 2013-11-25 10:31:11 ', ' yyyy-mm-dd HH24:MI:SS ')) as Afrom DUAL;

A

-----------

2013/11/30

3 Start time and end time of the season
    • Start time of season

Sql>select TRUNC (to_date (' 2013-11-25 10:31:11 ', ' yyyy-mm-dd HH24:MI:SS '), ' Q ') as Afrom DUAL;

A

-----------

2013/10/1

    • End time of the season

Sql>select add_months (TRUNC (to_date (' 2013-11-25 10:31:11 ', ' yyyy-mm-ddhh24:mi:ss '), ' Q '), 3)-1 as A from DUAL;

A

-----------

2013/12/31

4 Start time and end time of the year
    • Start time of year

Sql>select TRUNC (to_date (' 2013-11-25 10:31:11 ', ' yyyy-mm-dd HH24:MI:SS '), ' YYYY ') ASA from DUAL;

A

-----------

2013/1/1

    • The end time of the year is taken

Sql>select add_months (TRUNC (to_date (' 2013-11-25 10:31:11 ', ' yyyy-mm-ddhh24:mi:ss '), ' YYYY '), 1 as A from DUAL;

A

-----------

2013/12/31

Oracle takes week, month, quarter, and year start and end times

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.