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

Date comparison in sql

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

Share

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

1.DateAdd I, N, D adds a date to the date after a period. I set the unit of a period added by a date Date. For example, interval= "d" means that the unit of N is the day. The setting value of I is as follows: yyyy Year year Q Quarter quarter m Month month d Day day w Weekday week h Hour n Minute minutes Second seconds N numerical expression sets a date to add a period of time can be positive or negative value indicates that the date after the plus result is > date, the negative value indicates that the subtractive result is the date before date. D date to be added or subtracted. The example DateAdd "m", 1, "31-Jan-98") the result 28-Feb-98 shows that the date 31-Jan-98 plus one month results in 28-Feb-98 instead of 31-Fe-98. The example DateAdd "d", 20, "30-Jan-99") results on 1999-2-9 by adding a date 30-Jan-99 to a date 20 days later. 2.Day (a string or expression of a date) returns the "day" part of the date. The example Day ("12 FY 1999") result 1 3.DateDiff (I, D1, D2 [, FW [, FY]]) calculates the period between two dates. I sets the unit of calculation for the period between two dates. For example, > I = "m" indicates that the unit of calculation is month. > I setting values such as yyyy > Year Q Quarter quarter m Month month d Day day w Weekday week h Hour n Minute s Second seconds D1, D2 calculation period if the two date expressions > date1 earlier, the period between the two dates is positive if > date2 earlier, the result is negative. FW sets the first day of the week as the day of the week if it is not set as Sunday. > the setting value of FW is as follows: 0 use the setting value of > API. 1 Sunday 2 Monday 3 Tuesday 4 Wednesday 5 Thursday 6 Friday 7 Saturday FY sets the first week of the year if it is not set, the first week of January is the first week of the year. > the setting value of FY is as follows: 0 use the setting value of > API. 1 January 1st week is the first week of the year 2 includes at least four days the first week of the year 3 includes the first week of the year including seven days the first week of the year example DateDiff ("d", "25-Mar-99", "30-Jun-99") result 97 shows that the period between the two dates is 97 days

Example DateDiff ("d", "2005-06-07", "2005-06-09")

Result 2

Example DateDiff ("d", "2005-06-09", "2005-06-07")

Result-2

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: 262

*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