Add function to oracle date add operation in SQL Server

Source: Internet
Author: User

Add function to oracle date add operation in SQL Server

Oracle date add minutes
How does one add a day/hour/minute/second to a date value?
Submitted by admin on Wed, The SYSDATE pseudo-column shows the current system date and time. adding 1 to SYSDATE will advance the date by 1 day. use fractions to add hours, minutes or seconds to the date. look at these examples:


SQL> select sysdate, sysdate + 1/24, sysdate + 1/1440, sysdate + 1/86400 from dual;

SYSDATE + 1/24 SYSDATE + 1/1440 SYSDATE + 1/86400
--------------------------------------------------------------------------------
03-Jul-2002 08:32:12 03-Jul-2002 09:32:12 03-Jul-2002 08:33:12 03-Jul-2002 08:32:13
The following format is frequently used with Oracle Replication:


Select sysdate NOW, sysdate + 30/(24*60*60) NOW_PLUS_30_SECS from dual;

NOW NOW_PLUS_30_SECS
----------------------------------------
03-JUL-2005 16:47:23 03-JUL-2005 16:47:53
Here are a couple of examples:

Description Date Expression
Now SYSDATE
Tomorow/next day SYSDATE + 1
Seven days from now SYSDATE + 7
One hour from now SYSDATE + 1/24
Three hours from now SYSDATE + 3/24
An half hour from now SYSDATE + 1/48
10 minutes from now SYSDATE + 10/1440
30 seconds from now SYSDATE + 30/86400
Tomorrow at 12 midnight TRUNC (SYSDATE + 1)
Tomorrow at 8 am trunc (SYSDATE + 1) + 8/24
Next Monday at 12: 00 noon NEXT_DAY (TRUNC (SYSDATE), 'monday') + 12/24
First day of the month at 12 midnight TRUNC (LAST_DAY (SYSDATE) + 1)
The next Monday, Wednesday or Friday at 9. m TRUNC (LEAST (NEXT_DAY (sysdate, ''monday''), NEXT_DAY (sysdate, ''wednesday''), NEXT_DAY (sysdate, ''friday ''))) + (9/24)

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.