SQL Reference

Chapter 2 | Supported standards 32
Functions that return dates
Note The DATE() function is deprecated. Use the SQL standard CURRENT_DATE instead.
Conditional functions
Functions that return
dates Description Example
CURDATE
CURRENT_DATE
Returns today’s date
CURTIME
CURRENT_TIME
Returns the current time
CURTIMESTAMP
CURRENT_TIMESTAMP
Returns the current timestamp value
TIMESTAMPVAL Converts a character string to a
timestamp
TIMESTAMPVAL('2015-01-30 14:00:00')
returns its timestamp value
DATE
TODAY
Returns today’s date If today is 11/21/2015, DATE() returns 2015-11-21
DATEVAL Converts a character string to a date DATEVAL('2015-01-30') returns 2015-01-30
Conditional
functions Description Example
CASE WHEN Simple CASE format
Compares the value of input_exp to the values
of value_exp arguments to determine the result.
CASE input_exp
{WHEN value_exp THEN result...} [ELSE
result]
END
SELECT
Invoice_ID,
CASE Company_Name
WHEN 'Exports UK' THEN
'Exports UK Found'
WHEN 'Home Furniture
Suppliers' THEN 'Home Furniture
Suppliers Found'
ELSE 'Neither Exports UK
nor Home Furniture Suppliers'
END,
Salesperson_ID
FROM
Sales_Data
Searched CASE format
Returns a result based on whether the condition
specified by a WHEN expression is true.
CASE
{WHEN boolean_exp THEN result...} [ELSE
result]
END
SELECT
Invoice_ID,
Amount,
CASE
WHEN Amount > 3000 THEN 'Above
3000'
WHEN Amount < 1000 THEN 'Below
3000'
ELSE 'Between 1000 and 3000'
END,
Salesperson_ID
FROM
Sales_Data