Date/Time Functions

Advantage SQL Engine

DATE = Year, Month, Day.

TIME = hour, minute, second.

date = Expression or literal resulting in a date value.

time = Expression or literal resulting in a time value.

timestamp = Expression or literal resulting in a timestamp value.

timestampdiff = Expression or literal resulting in a timestamp value.

int = Expression or literal resulting in an integer value.

 

CURDATE( )

Returns DATE for current date with 1-based month.

CURRENT_DATE( )

Same as CURDATE.

CURRENT_TIME([ precision ])

Same as CURTIME, with optional precision seconds.

CURRENT_TIMESTAMP([ precision ])

Returns TIMESTAMP for current local time, with optional precision seconds.

CURTIME( )

Returns TIME for current local time, with optional precision seconds.

DAYNAME( date )

Returns weekday name string from CHAR|DATE|TIMESTAMP.

DAYOFMONTH( date )

Returns integer day of month (1-based) from CHAR|DATE|TIMESTAMP.

DAYOFWEEK( date )

Returns integer day of week (1-based, where 1 means Sunday) from CHAR|DATE|TIMESTAMP.

DAYOFYEAR( date )

Returns integer day of year (1-based) from CHAR|DATE|TIMESTAMP.

EXTRACT( time-value FROM time-date )

Extract year, month, day, hour, minute, or second from TIMESTAMP.

FRAC_SECOND( timestamp )

Returns integer millisecond from TIMESTAMP.

HOUR( time )

Returns integer of hour (0-based) from CHAR|TIME|TIMESTAMP.

MINUTE( time )

Returns integer minute (0-based) from CHAR|TIME|TIMESTAMP.

MONTH( date )

Returns integer of month (1-based) from CHAR|DATE|TIMESTAMP.

MONTHNAME( date )

Returns string month name from CHAR|DATE|TIMESTAMP.

NOW( )

Returns TIMESTAMP for current date and time (1-based month).

QUARTER( date )

Returns integer quarter number (1-4) from CHAR|DATE|TIMESTAMP.

SECOND( time )

Returns integer second (0-based) from CHAR|TIME|TIMESTAMP.

TIMESTAMPADD( interval, int, timestamp )

Returns TIMESTAMP calculated by adding int intervals to timestamp. Interval values supported are: SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY, SQL_TSI_WEEK, SQL_TSI_MONTH, SQL_TSI_QUARTER, SQL_TSI_YEAR.

TIMESTAMPDIFF( interval, timestamp1, timestamp2 )

Returns number of integer intervals based on subtracting timestamp1 from timestamp2. Interval values supported are: SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY, SQL_TSI_WEEK, SQL_TSI_MONTH, SQL_TSI_QUARTER, SQL_TSI_YEAR.

WEEK( date )

Returns integer week number (1-based) in year from CHAR|DATE|TIMESTAMP.

YEAR( date )

Returns integer year number from CHAR|DATE|TIMESTAMP.