The read-only analysis engine currently supports most MySQL date functions, but there are still limitations and incompatibilities in some scenarios. This document introduces the supported list of date functions in the read-only analysis engine and lists the type limitations in input parameters. If input parameters and functions are not mentioned in the document, they are not supported.
Supported Date Functions
datediff Function
A function that calculates the number of specified time intervals between two dates.
Syntax: datediff(date1, date2)
Supported value types for date1: Date and datetime data.
Supported value types for date2: Date and datetime data.
year Function
A function that calculates the year.
Syntax: year(date1)
Supported value types for date1: Date, datetime, char, and varchar data.
month Function
A function that calculates the month.
Syntax: month(date1)
Supported value types for date1: Date, datetime, char, and varchar data.
day Function
A function that calculates the current day number.
Syntax: day(date1)
Supported value types for date1: Date, datetime, char, and varchar data.
hour Function
A function that calculates the hour.
Syntax: hour(date1)
Supported value types for date1: Date and datetime data.
minute Function
A function that calculates the minute.
Syntax: minute(date1)
Supported value types for date1: Date and datetime data.
second Function
A function that calculates the second.
Syntax: second(date1)
Supported value types for date1: Date and datetime data.
microsecond Function
A function that returns the microsecond part of the time/date and time.
Syntax: microsecond(date1)
Supported value types for date1: Date and datetime data.
quarter Function
A function that returns the quarter of the year for the given date value (a number between 1 and 4).
Syntax: quarter(date1)
Supported value types for date1: Date, datetime, varchar, and char data.
date Function
Date function.
Syntax: date(date1)
Supported value types for date1: Date, datetime, char, and varchar data.
sysdate Function
A function that returns system time.
Syntax: sysdate()
date_add Function
A function that adds dates.
Syntax: date_add(date1, interval expr type)
Supported value types for date1: Date and datetime data.
Supported value types for expr: int, long, double, and decimal.
Supported value types for type: DAY, which is a keyword.
date_sub Function
A function that subtracts dates.
Syntax: date_sub(date1, interval expr type)
Supported value types for date1: Date and datetime data.
Supported value types for expr: int, long, double, and decimal.
Supported value types for type: DAY, which is a keyword.
dayofyear Function
A function that returns the day of the year for a given date.
Syntax: dayofyear(date1)
Supported value types for date1: Date, datetime, char, and varchar data.
dayofmonth Function
A function that returns the day of the month for a given date.
Syntax: dayofmonth(date1)
Supported value types for date1: Date, datetime, char, and varchar data.
dayofweek Function
A function that returns the day of the week for a given date.
Syntax: dayofweek(date1)
Supported value types for date1: Date, datetime, char, and varchar data.
dayname Function
A function that returns the name of the day of the week corresponding to the specified date.
Syntax: dayname(date1)
Supported value types for date1: Date, datetime, char, and varchar data.
monthname Function
A function that returns the name of the month corresponding to the specified date.
Syntax: monthname(date1)
Supported value types for date1: Date, datetime, char, and varchar data.
to_seconds Function
A function that returns the number of seconds counting from year 0 to the specified date/date and time.
Syntax: to_seconds(date1)
Supported value types for date1: Date, datetime, char, and varchar data.
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 data.
sleep Function
A function that pauses for a few seconds during execution.
Syntax: sleep(N)
Supported value types for N: int data.
now Function
A function that obtains the current time.
Syntax: NOW()
Obtain the current time without input parameters.
current_timestamp Function
A function that obtains the current time, equivalent to the NOW function.
Syntax: CURRENT_TIMESTAMP()
Obtain the current time without input parameters.
curdate Function
A function that obtains the current date, equivalent to the CURRENT_DATE function.
Syntax: CURDATE()
Obtain the current date without input parameters.
current_date Function
A function that obtains the current date, equivalent to the CURDATE function.
Syntax: CURRENT_DATE()
Obtain the current time without input parameters.
current_time Function
A function that obtains the current time.
Syntax: CURRENT_TIME()
Obtain the current time without input parameters.
curtime Function
A function that obtains the current time, equivalent to the CURRENT_TIME function.
Syntax: CURTIME()
Obtain the current time without input parameters.
from_unixtime Function
A function that converts timestamp to time format.
Syntax: FROM_UNIXTIME(unix_timestamp[,format])
unix_timestamp supports int type numbers.
The formats supported by format are shown in the table of date_format function below. If format is empty, the default format is %Y-%m-%d %H:%i:%s. unix_timestamp Function
A function that converts date and time to timestamp.
Syntax: UNIX_TIMESTAMP([date])
date supports the date type of 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 number of weeks 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)
Obtain 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
A function that formats a date.
Syntax: date_format(date1, format)
Supported value types for date1: Date, datetime, char, and varchar data, and do not support date1 containing null scenarios. format specifies the output format of date/time. The available formats are shown in the table below.
|
%a | Abbreviated names of the days of the week. |
%b | Abbreviated names of the months. |
%c | Month and numeric value. |
%D | Days of the month with English prefixes. |
%d | Day of the month; numeric value (00 - 31). |
%e | Day of the month; numeric value (0 - 31). |
%f | Microsecond. |
%H | Hour (00 - 23). |
%h | Hour (01 - 12). |
%I | Hour (01 - 12). |
%i | Minute; numeric value (00 - 59). |
%j | Day of the year (001 - 366). |
%k | Hour (0 - 23). |
%l | Hour (1 - 12). |
%M | Names of the months. |
%m | Month; numeric value (00 - 12). |
%p | AM or PM. |
%r | Time; 12-hour clock (hh:mm:ss AM or PM). |
%S | Second (00 - 59). |
%s | Second (00 - 59). |
%T | Time; 24-hour clock (hh:mm:ss). |
%U | Week (00 - 53). Sunday is the first day of the week. |
%u | Week (00 - 53). Monday is the first day of the week. |
%V | Week (01 - 53). Sunday is the first day of the week, used with %X. |
%v | Week (01 - 53). Monday is the first day of the week, used with %x. |
%W | Names of the days of the week. |
%w | Day of the week (0 = Sunday; 6 = Saturday). |
%X | Year, where Sunday is the first day of the week. The value contains 4 digits, used with %V. |
%x | Year, where Monday is the first day of the week. The value contains 4 digits, used with %v. |
%Y | Year (4 digits). |
%y | Year (2 digits). |