Oracle received 00:00:00 and 59 minutes 59 seconds on the same day

Source: Internet
Author: User
1. Get selectTRUNC (SYSDATE) FROMdual at 00:00:00 of the current day; 2. Get 23: 59: 59 seconds of the current day (add 1 day based on 00:00:00 of the current day and then minus 1 second) SEL

1. Get select TRUNC (SYSDATE) FROM dual; 2. Get 23: 59: 59 seconds on the current day (add 1 day after 00:00:00 on the current day and then subtract 1 second) SEL

1. Get 00:00:00 of the current day

Select TRUNC (SYSDATE) FROM dual;

2. Get 23: 59: 59 seconds on the current day (add one day and then minus one second on the basis of 00:00:00 on the current day)

Select trunc (SYSDATE) + 1-1/86400 FROM dual;

3. The current date is the day of the week. Note: Sunday is the first day of the week.

Select to_char (sysdate, 'D'), to_char (sysdate, 'day') from dual;

4. How to get the first and last days of the month in Oracle

Select to_char (sysdate, 'yyyy-mm') | '-01' firstday, to_char (last_day (sysdate), 'yyyy-mm-dd') lastday from dual

5. Implement the data before of the current day minus of the previous day, after minus of the current day

Select field1, field2 from mytablewhere time = decode (sign (sysdate-trunc (sysdate)-16/24), -- time judgment

-1, trunc (sysdate)-1 + 16/24, -- less than 16 points to get yesterday

Trunc (sysdate) + 16/24) -- value greater than 16 points for the current day

,

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.