Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

DateAdd () function in Sqlserver

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In the Sqlserver database, the DATEADD () function adds or subtracts the specified time interval from the date. For example, you can use the DateAdd () function to calculate the time of the current time to the next day and the time of the previous day. The format of the DateAdd () function is: DATEADD (datepart,number,date), where the datepart parameter is a legal date expression. Number is the number of intervals you want to add; for future times, it is positive, and for past times, it is negative.

Taking the current time of 23:57:30 on March 22nd, 2019 as an example, the following examples help to understand:

(1) add 1 day to the current time: Select dateadd (DD,1,GETDATE ())

(2) add 1 week to the current time: Select dateadd (WK,1,GETDATE ())

(3) add one month to the current time: Select dateadd (MMagne 1 ~ GETDATE ())

(4) add one quarter to the current time: Select dateadd (QJI GETDATE ())

(5) add one year to the current time: Select dateadd (YY,1,GETDATE ())

Note: this article was first published in the blog's personal blog IT technology fun room, the original Sqlserver DateAdd () function _ IT technology fun room, reproduced please indicate the source.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 251

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report