Oracle Date Processing

Source: Internet
Author: User

Oracle date processing -- calculate the year month day select to_char (sysdate, 'yyyymmdd'), sysdate from dual; -- calculate the year month day system yesterday select to_char (sysdate-1, 'yyyymmdd'), sysdate from dual; -- calculate the day before yesterday of the year, month, and day system select to_char (sysdate-2, 'yyyymmdd'), sysdate from dual; -- calculate the year, month, and day system tomorrow select to_char (sysdate + 1, 'yyyymmdd '), sysdate from dual; -- calculate the acquired select to_char (sysdate + 2, 'yyyymmdd'), sysdate from dual; -- calculate weekly select to_char (sysdate, 'yyyww '), sysdate from dual; -- 201248 -- year and month (number) select to_number (to_char (sysdate, 'yyymmm ') from dual; -- 201211 -- year and month (character) select to_char (sysdate, 'yyyymm') from dual; -- 201211 -- month (number) select to_number (to_char (sysdate, 'mm') from dual; -- 11 -- month (character) select to_CHAR (sysdate, 'mm') from dual; -- 11 select to_CHAR (to_date ('20170101', 'yyymmm'), 'mm') from dual; -- 01 select to_CHAR (to_date (select to_number (to_char (sysdate, 'yyyymm') from dual), 'yyyymm'), 'mm') from dual; -- 11 SELECT TO_NUMBER (TO_CHAR (TO_DATE ('201312', 'yyymmm'), 'mm') from dual; cycle date declare -- Local variables here I integer; a varchar2 (100); begin -- Test statements here I: = 0; while I <31 loop select to_char (to_date ('2013', 'yyyymmdd') + I, 'yyyymmdd') into a from dual; dbms_output.put_line (I | ':' | a); I: = I + 1; end loop; end;

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.