-
sysdatetime
sysdatetime()
Returns a datetime2(7) value containing the date and time of the computer on which theinstance of SQL Server runs. The returned value doesn't includethe timezone offset. -
sysdatetimeoffset
sysdatetimeoffset()
Returns a datetimeoffset(7) value containing the dateand time of the computer on which the instance of SQL Server runs. The returned value includes thetime zone offset. -
SYSUTCDATETIME
SYSUTCDATETIME()
Returns a datetime2(7) value containing the date and time of the computer on which the instance of SQL Server is running. Thefunction returns the dateand time values as UTC time (Coordinated UniversalTime). -
CURRENT_TIMESTAMP
CURRENT_TIMESTAMP
Returns a datetime value containing the date and time of the computer on which the instance of SQL Server runs. The returned value doesn't include the time zone offset. -
GETDATE
GETDATE()
Returns a datetime value containing the date and time of the computer on which the instance of SQL Server runs. The returned value doesn't include the time zone offset.
6.GETUTCDATE
GETUTCDATE()
Returns a datetime value containing the date and time of the computer on which the instance of SQL Server runs. The function returns the date and time values as UTC time (Coordinated UniversalTime).
datePart | 缩写形式 |
---|---|
day | dd, d |
week | wk, ww |
month | mm, m |
quarter | qq, q |
year | yy, yyyy |
hour | hh |
minute | mi, n |
second | ss, s |
millisecond | ms |
-
DATE_BUCKET 待理解
DATE_BUCKET(datepart, number, date, origin)
Returns a value corresponding to the start of each date-time bucket from the timestamp defined by the origin parameter, or the default origin value of 1900-01-01 00:00:00.000 if the origin parameter isn't specified. -
DATENAME
DATENAME ( datepart, date)
Returns a character string representing the specified datepart of the specified date.
获取时间的一部分。返回类型是字符串 -
DATEPART
DATEPART( datepart, date)
Returns an integer representing the specified datepart of the specified date.
同上,但是返回类型是数值 -
DATETRUNC
'DATETRUNC' 不是可以识别的 内置函数名称。
DATETRUNC ( datepart, date)
Returns an input date truncated to a specified datepart. -
DAY/MONTH/YEAR
fun(date)
Returns an integer representing the DAY/MONTH/YEAR part of the specified date. -
DATEFROMPARTS
DATEFROMPARTS( year, month, day )
Returns a date d value for the specified year, month, and day.
fractions:精度毫秒位的值
precision:精度
若精度为1,fraction单位为100ms,精度为2,单位为10ms,以此类推。
-
DATETIME2FROMPARTS
DATETIME2FROMPARTS( year, month, day, hour, minute, seconds, fractions, precision)
Returns a datetime2 value for the specified date and time, with the specified precision. -
DATETIMEFROMPARTS
DATETIMEFROMPARTS( year, month, day, hour, minute, seconds, milliseconds)
Returns a datetime value for the specified date and time. -
DATETIMEOFFSETFROMPARTS
DATETIMEOFFSETFROMPARTS( year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision)
Returns a datetimeoffset value for the specified date and time, with the specified offsets and precision. -
SMALLDATETIMEFROMPARTS
SMALLDATETIMEFRO MPARTS( year, month, day, hour, minute)
Returns a smalldatetime value for the specified date and time. -
TIMEFROMPARTS
TIMEFROMPARTS( hour, minute, seconds, fractions, precision )
Returns a time t value for thespecified time, with thespecified precision. -
DATEDIFF
DATEDIFF ( datepart, startdate, enddate)
根据datepart的基准比较两个时间的差值
Returns the number of date or time datepart boundaries, crossed between two specified dates. -
DATEDIFF_BIG
DATEDIFF_BIG ( datepart, startdate, enddate)
同上,但返回值支持bigint
Returns the number of date or time datepart boundaries, crossed between two specified dates. -
DATEADD
DATEADD (datepart, number, date)
Returns a new datetime value by adding an interval to the specified datepart of the specified date. -
EOMONTH
EOMONTH ( start_date[, month_to_add ] )
Returns the last day of the month containing the specified date, with an optional offset. -
SWITCHOFFSET
SWITCHOFFSET (DATETIMEOFFSET, time_zone)
SWITCHOFFSET changes the time zone offset of a DATETIMEOFFSET value, and preserves the UTC value.
只改时区,不改时间 -
TODATETIMEOFFSET
TODATETIMEOFFSET (expression, time_zone)
TODATETIMEOFFSET transforms a datetime2 value into a datetimeoffset value. TODATETIMEOFFSET interprets the datetime2 value in local time, for the specified time_zone.