Oracle gets the full date one months before the current date

Source: Internet
Author: User

The current date is 2018/08/12.

1. Get the number of days in the current month:

Select To_number (To_char (Last_day (sysdate), ' DD ')) from dual

2. Get the full date 30 days before the current date.

Select trunc (sysdate-+)+ as from by RowNum<=  ;

The results of the implementation are as follows:

2. Get the full date for the one months preceding the current date. The one months here will be given the number of days of the month based on the current month, which may be 31, 30, or 29 days.

Select trunc (sysdate-to_number (To_char (Last_day (sysdate),'dd')) +  as  from  by rownum<=to_number (To_char (Last_day (sysdate),'dd'))

The results of the implementation are as follows:

4. Get the current day of the week (including the current date).

Select trunc (sysdate-7)+ as from by RowNum<=  7

5. Get the current day of the week (not including the current date).

Select trunc (sysdate-8)+ as from RowNum<=7

Or

Select trunc (sysdate-7)+rownum-1 as from  by rownum<=7

The results of the implementation are as follows:

6. Get 10 consecutive digits starting from 10

Select Ten +  as  from  by rownum<=;

Oracle gets the full date one months before the current date

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.