MySQL functions

GoogleSQL for Spanner supports the following MySQLfunctions. You need to install the MySQL functions in yourSpanner database before you can use them. For more information oninstalling the functions, seeInstall MySQL functions.

MySQL function list

NameSummary
mysql.BIN_TO_UUIDConverts a binary UUID representation to a STRING representation.
mysql.BIT_LENGTHReturns the length of string in bits.
mysql.CHAR Interprets the input parameter as an integer and returns a byte string consisting of the character given by the code value of that integer.
mysql.CONCAT_WSReturns a concatenated string with separators.
mysql.DATE_FORMATFormats a date as specified.
mysql.DATEDIFFSubtracts two dates and returns the number of days between them.
mysql.DAY Alias forDAYOFMONTH. Returns the day of the month (1-31) from aTIMESTAMP value.
mysql.DAYNAMEReturns the name of the weekday.
mysql.DAYOFMONTHReturns the day of the month (1-31).
mysql.DAYOFWEEKReturns the weekday index of the input parameter.
mysql.DAYOFYEARReturns the day of the year (1-366).
mysql.DEGREESConverts radians to degrees.
mysql.FROM_DAYSConverts a day number to a date.
mysql.FROM_UNIXTIMEFormats a Unix timestamp as a date.
mysql.HEXReturns the hexadecimal representation of a string.
mysql.HOURReturns the hour (0-23).
mysql.INET_ATONReturns the numeric value of an IP address.
mysql.INET_NTOAReturns the IP address from a numeric value.
mysql.INET6_ATONReturns the numeric value of an IPv6 address.
mysql.INET6_NTOAReturns the IPv6 address from a numeric value.
mysql.INSERTInserts a substring at a specified position up to a specified number of characters.
mysql.IS_IPV4Checks whether the input parameter is an IPv4 address.
mysql.IS_IPV4_COMPATReturns whether the input parameter is an IPv4-compatible address.
mysql.IS_IPV4_MAPPEDReturns whether the input parameter is an IPv4-mapped address.
mysql.IS_IPV6Returns whether the input parameter is an IPv6 address.
mysql.IS_UUIDReturns whether the input parameter is a valid UUID. Not available in MySQL 5.7.
mysql.JSON_QUOTEQuotes the JSON document.
mysql.JSON_UNQUOTEUnquotes the JSON value.
mysql.LOCALTIME Alias forNOW. Returns theTIMESTAMP for when the query statement containing this function started to run.
mysql.LOCALTIMESTAMPReturns theTIMESTAMP when the query statement containing this function started to run.
mysql.LOCATEReturns the position of the first occurrence of a substring. The search is case insensitive.
mysql.LOG2Returns the base-2 logarithm of the input argument. ReturnsNULL if the input argument is out of range.
mysql.MAKEDATECreates a date from the year and day of year.
mysql.MICROSECONDReturns the microseconds from the input parameter.
mysql.MIDAlias forSUBSTRING.
mysql.MINUTEReturns the minute from the input parameter.
mysql.MONTHReturns the month from the date passed.
mysql.MONTHNAMEReturns the name of the month.
mysql.NOWReturns theTIMESTAMP when the query statement containing this function started to run.
mysql.OCTReturns a string containing an octal representation of a number.
mysql.ORDReturns the character code for the leftmost character of the input parameter.
mysql.PERIOD_ADDAdds a period to a year-month.
mysql.PERIOD_DIFFReturns the number of months between periods.
mysql.PIReturns the value of pi.
mysql.POSITIONAlias for LOCATE. Returns the starting position of the first occurrence of the substring.
mysql.QUARTERReturns the quarter from a date input parameter.
mysql.QUOTEEscapes the input parameter for use in a SQL statement.
mysql.RADIANSConverts degrees to radians.
mysql.REGEXP_LIKEReturnsTRUE if the string matches a regular expression. Not available in MySQL 5.7.
mysql.REGEXP_SUBSTRReturns a substring matching a regular expression. Not available in MySQL 5.7.
mysql.SECONDReturns the second (0-59).
mysql.SHA2Calculates a SHA-2 checksum.
mysql.SPACEReturns a string of the specified number of spaces.
mysql.STR_TO_DATEConverts a string to a date.
mysql.STRCMPCompares two strings.
mysql.SUBSTRING_INDEXReturns a substring from a string before the specified number of occurrences of the delimiter. Performs a case-sensitive match when searching for the delimiter.
mysql.SYSDATEReturns theTIMESTAMP when the query statement containing this function started to run.
mysql.TIMEExtracts the time portion of the expression passed.
mysql.TO_DAYSReturns the date input parameter converted to days.
mysql.TO_SECONDSReturns the date or datetime input parameter converted to seconds since Year 0.
mysql.TRUNCATETruncates a number to a specified number of decimal places.
mysql.UNHEXReturns a string containing the hex representation of a number.
mysql.UNIX_TIMESTAMPReturns a Unix timestamp.
mysql.UTC_DATEReturns the current UTC date.
mysql.UTC_TIMESTAMPReturns theTIMESTAMP when the query statement containing this function started to run.
mysql.UUIDReturns a Universal Unique Identifier (UUID).
mysql.UUID_TO_BINConverts a string representation of a UUID to a binary representation.
mysql.WEEKReturns the week number.
mysql.WEEKDAYReturns the weekday index.
mysql.WEEKOFYEARReturns the calendar week of the date (1-53).
mysql.YEARReturns the year.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.