Currently, the read-only analysis engine supports most of MySQL's date functions, but there are still limitations and incompatibilities in certain scenarios. This document introduces the list of supported date functions in the read-only analysis engine, and enumerates type restrictions on input parameters. Input parameters and functions not mentioned in the document are not supported.
Supported Date Function Types
datediff Function
A function that returns the number of specified time intervals between two dates.
Syntax: datediff(date1, date2)
Supported value types for date1: date and datetime.
Supported value types for date2: date and datetime.
year Function
A function that calculates the year.
Syntax: year(date1)
Supported value types for date1: date, datetime, char, and varchar.
month Function
A function that calculates the month.
Syntax: month(date1)
Supported value types for date1: date, datetime, char, and varchar.
day Function
A function that calculates the number of the day.
Syntax: day(date1)
Supported value types for date1: date, datetime, char, and varchar.
hour Function
A function that calculates the hour.
Syntax: hour(date1)
Supported value types for date1: date and datetime.
minute Function
A function that calculates the minute.
Syntax: minute(date1)
Supported value types for date1: date and datetime.
second Function
A function that calculates the second.
Syntax: second(date1)
Supported value types for date1: date and datetime.
microsecond Function
It returns the microsecond part of the time/datetime.
Syntax: microsecond(date1)
Supported value types for date1: date and datetime.
quarter Function
It returns the quarter of the year for a given date value (a number between 1 and 4).
Syntax: quarter(date1)
Supported value types for date1: date, datetime, varchar, and char.
date Function
Date function.
Syntax: date(date1)
Supported value types for date1: date, datetime, char, and varchar.
sysdate Function
A function that returns the system time.
Syntax: sysdate()
date_add Function
Date addition function.
Syntax: date_add(date1, interval expr type)
Supported value types for date1: date and datetime.
Supported value types for expr: int, long, double, and decimal.
Supported value types for type: DAY, which is the keyword.
date_sub Function
Date subtraction function.
Syntax: date_sub(date1, interval expr type)
Supported value types for date1: date and datetime.
Supported value types for expr: int, long, double, and decimal.
Supported value types for type: DAY, which is the keyword.
dayofyear Function
A function that returns the day number of a given date in the year.
Syntax: dayofyear(date1)
Supported value types for date1: date, datetime, char, and varchar.
dayofmonth Function
A function that returns the day number of a given date in the month.
Syntax: dayofmonth(date1)
Supported value types for date1: date, datetime, char, and varchar.
dayofweek Function
A functions that returns the day number of a given date in the week.
Syntax: dayofweek(date1)
Supported value types for date1: date, datetime, char, and varchar.
dayname Function
A function that returns the name of the week corresponding to a specified date.
Syntax: dayname(date1)
Supported value types for date1: date, datetime, char, and varchar.
monthname Function
A function that returns the name of the month corresponding to a specified date.
Syntax: monthname(date1)
Supported value types for date1: date, datetime, char, and varchar.
to_seconds Function
A function that returns the number of seconds since year 0 for a specified date/datetime.
Syntax: to_seconds(date1)
Supported value types for date1: date, datetime, char, and varchar.
last_day Function
A function that returns the last day of the month.
Syntax: last_day(date1)
Supported value types for date1: date, datetime, char, and varchar.
sleep Function
A function that pauses the execution for a few seconds.
Syntax: sleep(N)
Supported value types for N: int.
now Function
A function that obtains the current time.
Syntax: NOW()
This function obtains the current time and does not require input parameters.
current_timestamp Function
A function that obtains the current time. It is equivalent to the NOW function.
Syntax: CURRENT_TIMESTAMP()
This function obtains the current time and does not require input parameters.
curdate Function
A function that obtains the current date. It is equivalent to the CURRENT_DATE function.
Syntax: CURDATE()
This function obtains the current date and does not require input parameters.
current_date Function
A function that obtains the current date. It is equivalent to the CURDATE function.
Syntax: CURRENT_DATE()
This function obtains the current time and does not require input parameters.
current_time Function
A function that obtains the current time.
Syntax: CURRENT_TIME()
This function obtains the current time and does not require input parameters.
curtime Function
A function that obtains the current time. It is equivalent to the CURRENT_TIME function.
Syntax: CURTIME()
This function obtains the current time and does not require input parameters.
from_unixtime Function
A function that converts timestamp to time.
Syntax: FROM_UNIXTIME(unix_timestamp[,format])
unix_timestamp supports int type numbers.
The formats supported by format are shown in the table of the date_format function below. If format is left blank, the default format %Y-%m-%d %H:%i:%s is used. unix_timestamp Function
A function that converts date and time to timestamp.
Syntax: UNIX_TIMESTAMP([date])
date supports date values that comply with the DATE standard.
Note:
Only 1.2404.17.0 and later versions support the FROM_UNIXTIME function and the UNIX_TIMESTAMP function.
weekday Function
A function that obtains the week corresponding to the parameter value.
Syntax: weekday(date)
This function obtains the day in a week corresponding to a date. The input parameter supports Date or Datetime values. The returned result range is 0 to 6, which respectively corresponds to Sunday to Saturday. If the date is NULL or 0000-00-00, the function returns NULL.
timediff Function
Obtain the difference between two times.
Syntax: timediff(time1,time2)
This function obtains the time difference between time1 and time2 (time1 - time2).
to_days Function
A function that obtains the number of days between December 31, 0 A.D. and the input parameter value.
Syntax: to_days(date)
This function obtains the number of days between the input value and 0 A.D. The input parameter supports Date or string values. The returned result is of numeric type.
yearweek Function
This function is used to obtain the year and week number of a specified date.
Syntax: yearweek(date[,mode])
This function returns a week number. In this function, date is the date to be calculated (for example, "2025-06-15"); mode is an optional parameter used to specify the start day of a specified week. The value of this parameter is 0 by default, indicating that the start day of a week is Sunday. The return result is of the numeric type.
time Function
This function is used to obtain the time part of a time or date expression and returns a string.
Syntax: time(expr)
This function returns the time. expr can be the time type or the date and time type. The return value is a string. If expr is empty, an empty result will be returned.
date_format Function
Date formatting function.
Syntax: date_format(date1, format)
Supported value types for date1: date, datetime, char, and varchar. NULL is not supported. format specifies the output format of the date/time. Available formats are listed in the table below.
|
%a | Abbreviated weekday name. |
%b | Abbreviated month name. |
%c | Month, numeric. |
%D | The day of the month with an English prefix. |
%d | The day of the month, numeric (00 - 31). |
%e | The day of the month, numeric (0 - 31). |
%f | Microsecond. |
%H | Hour (00 - 23). |
%h | Hour (01 - 12). |
%I | Hour (01 - 12). |
%i | Minute, numeric (00 - 59). |
%j | The day of the year (001 - 366). |
%k | Hour (0 - 23). |
%l | Hour (1 - 12). |
%M | Month name. |
%m | Month, numeric (00 - 12). |
%p | AM or PM. |
%r | Time, 12-hour (hh:mm:ss AM or PM). |
%S | Second (00 - 59). |
%s | Second (00 - 59). |
%T | Time, 24-hour (hh:mm:ss). |
%U | Week (00 - 53). Sunday is the first day of a week. |
%u | Week (00 - 53). Monday is the first day of a week. |
%V | Week (01 - 53). Sunday is the first day of a week. It is used with %X. |
%v | Week (01 - 53). Monday is the first day of a week. It is used with %x. |
%W | Weekday name. |
%w | The day of the week (0 = Sunday, 6 = Saturday). |
%X | Year. Sunday is the first day of a week. It contains 4 digits, and is used with %V. |
%x | Year. Monday is the first day of a week. It contains 4 digits, and is used with %v. |
%Y | Year, containing 4 digits. |
%y | Year, containing 2 digits. |