SQL Server Date Time Function

xiaoxiao2021-03-19  201

SQL Server Date Time Function

<- .fish_1 {border: 1px solid #cccccc;} .style1 {font-size: 14px; font-weight: bold;} ->

Date and time function in SQL Server 1. Current system date, time select getdate () 2. DateAdd Returns a new DateTime value on the basis of adding a period of time to the specified date, for example: add 2 days to SELECT DATEADD ( Day, 2, '2004-10-15') - Back: 2004-10-17 00: 00.000 3. DateDiff Returns the number of times and time boundaries across two specified dates. Select Datediff (Day, '2004-09-01', '2004-09-18') - Returns: 17 4. DatePart Returns an integer that represents the specified date part of the specified date. Select DatePart (Month, '2004-10-15') - Returns 10 5. Datename Returns String Select Datename (WeekDay, '2004-10-15') on behalf of the specified date of the specified date - Back: Friday 6 Day (), Month (), Year () - can be with DatePart Current Date = Convert (VARCHAR (10), Getdate (), 120), Current Time = Convert (VARCHAR (8), getDate () , 114) SELECT DATENAME (DW, '2004-10-15') SELECT Most of the year = Datename (Week, '2004-10-15'), today is a few days = Datename (Weekday, '2004-10- 15 ')

Function Parameters / Function GetDate () Returns the current date and time datediff (interval, date1, date2) in an interval specified by interval, return Date2 and Date1 Date1Dateadd (Interval, Number, Date) In the interval specified, add the date DatePart (Interval, Date) after Number Date, the integer value DateName (Interval, Date) corresponding to the interval specified part is Date Date, the interse specified section corresponding to the string The set value of the name parameter interval is as follows:

转载请注明原文地址:https://www.9cbs.com/read-130089.html

New Post(0)