Unit 5 Flashcards
(39 cards)
function produces a date by adding a specified number to a specified part of a date.
DATEADD
function returns the difference between two parts of a date.
DATEDIFF
function subtracts a specified time interval from a date.
DATE_SUB()
function returns the specified part of the date requested.
DATEPART
function is used to return a single part of a date/time, such as year, month, day, hour, minute, etc.
EXTRACT()
function will extract the year from a value stored as a SMALLDATETIME data type.
YEAR
function will extract the month from a date.
MONTH
function extracts the day of the month from a date
DAY
function returns the current system date and time
GETDATE
function returns the current system date and time in Universal Time Coordinate Format, useful for getting date and time of other location.
GETUTCDATE
Returns the current date and time
NOW()
Returns the current date
CURDATE()
Returns the current time
CURTIME()
Returns the current utc date
UTC_DATE()
Returns the current utc time
UTC_TIME()
operate on values in single rows, one row at a time.
Row-level Functions
function rounds numbers to a specified number of decimal places.
ROUND
(attribute), which returns the next larger integer value when a number contains decimal places.
CEILING
(attribute), which returns the next lower integer value when a number contains decimal places.
FLOOR
(attribute), which returns the square root of positive numeric values.
SQRT
(attribute), which returns the absolute value of any numeric value.
ABS
(attribute), which returns a number squared.
SQUARE
To handle the null issue, SQL Server provides a row-level function, which returns a value if a table value is null.
Isnull
A function, which returns a NULL if expression1 = expression2. If the expressions are not equal, then expression1 is returned.
NULLIF