All Products
Search
Document Center

Functions

Last Updated: Sep 16, 2020

1. Aggregate functions

Aggregate function Parameter type Return type Return value
avg(expression) SMALLINT, INT, BIGINT, FLOAT, and DOUBLE Same as the data type of the values that are specified by the expression The average of the values that are specified by the expression
count(*) N/A BIGINT The total number of rows
count(expression) The values specified by the expression can be of any data type. BIGINT The number of values that are not null
count(distinct expression) The values specified by the expression can be of any data type. The number of unique values that are not null
max(expression) SMALLINT, INT, BIGINT, FLOAT, DOUBLE, and VARCHAR Same as the data type of the values that are specified by the expression The maximum value that is specified by the expression
min(expression) SMALLINT, INT, BIGINT, FLOAT, DOUBLE, and VARCHAR Same as the data type of the values that are specified by the expression The minimum value that is specified by the expression
ts_last(expression, timestamp) The data types supported by the expression placeholder are DOUBLE, VARCHAR, and BOOLEAN. The data type supported by the timestamp placeholder is TIMESTAMP. Same as the data type of the values that are specified by the expression The value at the latest timestamp after the values specified by the expression are sorted by timestamp
ts_first(expression, timestamp) The data types supported by the expression placeholder are DOUBLE, VARCHAR, and BOOLEAN. The data type supported by the timestamp placeholder is TIMESTAMP. Same as the data type of the values that are specified by the expression The value at the earliest timestamp after the values specified by the expression are sorted by timestamp

2. Mathematical functions

TSQL supports the mathematical functions listed in the following table and the trigonometric functions listed in the next section. The following data types are supported for the input values for most of the mathematical functions and all of the trigonometric functions:

  • INT
  • BIGINT
  • FLOAT
  • DOUBLE
  • SMALLINT
Function Return type Description
ABS(x) Same as the data type of the input value Returns the absolute value of x.
CBRT(x) FLOAT8 Returns the cube root of x.
CEIL(x) Same as the data type of the input value Returns the smallest integer that is greater than or equal to x.
CEILING(x) Same as the data type of the input value Returns the smallest integer that is greater than or equal to x.
DEGREES(x) FLOAT8 Converts x radians to degrees.
E() FLOAT8 Returns 2.718281828459045.
EXP(x) FLOAT8 Returns e raised to the power of x.
FLOOR(x) Same as the data type of the input value Returns the largest integer that is smaller than or equal to x.
LOG(x) FLOAT8 Returns the base e logarithm of x.
LOG(x, y) FLOAT8 Returns the base x logarithm of y.
LOG10(x) FLOAT8 Returns the base 10 logarithm of x.
LSHIFT(x, y) Same as the data type of the input value Shifts the binary x by y times to the left.
MOD(x, y) FLOAT8 Returns the remainder of x divided by y.
NEGATIVE(x) Same as the data type of the input value Returns x as a negative number.
PI FLOAT8 Returns Pi.
POW(x, y) FLOAT8 Returns x raised to the power of y.
RADIANS(x) FLOAT8 Converts x degrees to radians.
RAND FLOAT8 Returns a random number that ranges from 0 to 1.
ROUND(x) Same as the data type of the input value Rounds to the nearest integer.
RSHIFT(x, y) Same as the data type of the input value Shifts the binary x by y times to the right.
SIGN(x) INT Returns the sign of x.
SQRT(x) Same as the data type of the input value Returns the square root of x.
TRUNC(x, y) DOUBLE Truncates x to y decimal places. In this function, y is optional. The default value is 0.

Examples

The math_func_demo table is used in the following examples of mathematical function. The math_func_demo table contains the following data.

  1. select * from math_func_demo;
  2. +---------------+-----------------------+
  3. | integer | float |
  4. +---------------+-----------------------+
  5. | 2010 | 17.4 |
  6. | -2002 | -1.2 |
  7. | 2001 | 1.2 |
  8. | 6005 | 1.2 |
  9. +---------------+-----------------------+
  • ABS(x)
  1. SELECT ABS(`integer`) FROM math_func_demo;
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | 2010 |
  6. | 2002 |
  7. | 2001 |
  8. | 6005 |
  9. +------------+
  10. 4 rows selected (0.357 seconds)
  • CEIL(x)
  1. SELECT CEIL(`float`) FROM math_func_demo;
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | 18.0 |
  6. | -1.0 |
  7. | 2.0 |
  8. | 2.0 |
  9. +------------+
  10. 4 rows selected (0.647 seconds)
  • FLOOR(x)
  1. SELECT FLOOR(`float`) FROM math_func_demo;
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | 17.0 |
  6. | -2.0 |
  7. | 1.0 |
  8. | 1.0 |
  9. +------------+
  10. 4 rows selected (0.11 seconds)
  • ROUND(x) and ROUND(x, y):The ROUND(x) and Round (x, y) function examples return the nearest integer and an approximate number that is rounded to four decimal places, respectively.
  1. SELECT ROUND(`float`) FROM math_func_demo;
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | 3.0 |
  6. | -1.0 |
  7. | 1.0 |
  8. | 1.0 |
  9. +------------+
  10. 4 rows selected (0.061 seconds)
  11. SELECT ROUND(`float`, 4) FROM math_func_demo;
  12. +------------+
  13. | EXPR$0 |
  14. +------------+
  15. | 3.1416 |
  16. | -1.2 |
  17. | 1.2 |
  18. | 1.2 |
  19. +------------+
  20. 4 rows selected (0.059 seconds)
  • LOG(x, y), LOG10(x), and LOG(x)The LOG(x, y), LOG10(x), and LOG(x) function examples return the base 2 logarithm of 64, the base 10 logarithm of 100, and the base e logarithm of 7.5, respectively.
  1. SELECT LOG(2, 64) FROM (VALUES(1));
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | 6.0 |
  6. +------------+
  7. 1 row selected (0.069 seconds)
  8. SELECT LOG10(100) FROM (VALUES(1));
  9. +------------+
  10. | EXPR$0 |
  11. +------------+
  12. | 2.0 |
  13. +------------+
  14. 1 row selected (0.203 seconds)
  15. SELECT LOG(7.5) FROM (VALUES(1));
  16. +---------------------+
  17. | EXPR$0 |
  18. +---------------------+
  19. | 2.0149030205422647 |
  20. +---------------------+
  21. 1 row selected (0.139 seconds)

3. Trigonometric functions

TSQL supports the following trigonometric functions. These functions return values of the FLOAT8 data type.

  • SIN(x)
    Returns the sine of x.
  • COS(x)
    Returns the cosine of x.
  • TAN(x)
    Returns the tangent of x.
  • ASIN(x)
    Returns the arcsine of x.
  • ACOS(x)
    Returns the arccosine of x.
  • ATAN(x)
    Returns the arctangent of x.
  • SINH(x)
    Returns the hyperbolic sine of x.
  • COSH(x)
    Returns the hyperbolic cosine of x.
  • TANH(x)
    Returns the hyperbolic tangent of x.

Examples

  1. SELECT RADIANS(30) AS Degrees FROM (VALUES(1));
  2. +------------+
  3. | Degrees |
  4. +------------+
  5. | 0.7853981633974483 |
  6. +------------+
  7. 1 row selected (0.045 seconds)
  8. SELECT SIN(0.7853981633974483) AS `Sine of 30 degrees` FROM (VALUES(1));
  9. +-----------------------+
  10. | Sine of 45 degrees |
  11. +-----------------------+
  12. | 0.7071067811865475 |
  13. +-----------------------+
  14. 1 row selected (0.059 seconds)
  15. SELECT TAN(0.7853981633974483) AS `Tangent of 30 degrees` from (VALUES(1));
  16. +-----------------------+
  17. | Tangent of 45 degrees |
  18. +-----------------------+
  19. | 0.9999999999999999 |
  20. +-----------------------+

4. String functions

The following table lists the string functions that are supported by TSQL.

Function Return type
CONCAT VARCHAR
INITCAP VARCHAR
LENGTH INT
LOWER VARCHAR
LPAD VARCHAR
LTRIM VARCHAR
REGEXP_REPLACE VARCHAR
RPAD VARCHAR
RTRIM VARCHAR
STRPOS INT
SUBSTR VARCHAR
TRIM VARCHAR
UPPER VARCHAR

Examples

  • CONCAT

Syntax: CONCAT(string [,string [, ...]])
The CONCAT function connects strings.

  1. SELECT CONCAT('Drill', ' ', 1.0, ' ', 'release') FROM (VALUES(1));
  2. +--------------------+
  3. | EXPR$0 |
  4. +--------------------+
  5. | Drill 1.0 release |
  6. +--------------------+
  7. 1 row selected (0.134 seconds)
  • INITCAP

Syntax: INITCAP(string)
The INITCAP function returns a string where the first character is capitalized.

  1. SELECT INITCAP('china beijing') FROM (VALUES(1));
  2. +---------------------------+
  3. | EXPR$0 |
  4. +---------------------------+
  5. | China Beijing |
  6. +---------------------------+
  7. 1 row selected (0.106 seconds)
  • LENGTH

Syntax: LENGTH(string [, encoding])
The LENGTH function returns the number of characters in a string.

  1. SELECT LENGTH('Hangzhou') FROM (VALUES(1));
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | 8 |
  6. +------------+
  7. 1 row selected (0.127 seconds)
  • LOWER

Syntax: LOWER(string)
The LOWER function converts uppercase characters in a string to lowercase characters.

  1. SELECT LOWER('China Beijing') FROM (VALUES(1));
  2. +---------------+
  3. | EXPR$0 |
  4. +---------------+
  5. | china beijing |
  6. +---------------+
  7. 1 row selected (0.103 seconds)
  • LPAD

Syntax: LPAD(string,length [, fill text])
The LPAD function left-pads a string to a specified length with the fill text. If the fill text fails to pad the string to the specified length, spaces are added to pad the string to the specified length. If the string length exceeds the specified length, the string is truncated to the specified length.

  1. SELECT LPAD('hi', 5, 'xy') FROM (VALUES(1));
  2. +------------------------------+
  3. | EXPR$0 |
  4. +------------------------------+
  5. | xyxhi |
  6. +------------------------------+
  7. 1 row selected (0.132 seconds)
  • LTRIM

Syntax: LTRIM(string1, string2)
The LTRIM function removes all the characters that are contained in the specified set (string2) from the left side of the input string (string1).

  1. SELECT LTRIM('zzzytest', 'xyz') FROM (VALUES(1));
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | test |
  6. +------------+
  7. 1 row selected (0.131 seconds)
  • REGEXP_REPLACE

Syntax: REGEXP_REPLACE(source_char, pattern, replacement)
The REGEXP_REPLACE function replaces the substrings that match the Java regular expression pattern in the string with the specified characters.

  1. SELECT REGEXP_REPLACE('abc, acd, ade, aef', 'a', 'b') FROM (VALUES(1));
  2. +---------------------+
  3. | EXPR$0 |
  4. +---------------------+
  5. | bbc, bcd, bde, bef |
  6. +---------------------+
  7. 1 row selected (0.105 seconds)
  8. SELECT REGEXP_REPLACE('abc, acd, ade, aef', 'a.','b') FROM (VALUES(1));
  9. +-----------------+
  10. | EXPR$0 |
  11. +-----------------+
  12. | bc, bd, be, bf |
  13. +-----------------+
  14. 1 row selected (0.113 seconds)
  • RPADSyntax: RPAD (string, length [, fill text])
    The RPAD function right-pads a string to the specified length. If you do not specify the fill text or the fill text fails to pad the string to the specified length, spaces are added to the end of the specified characters. The specified characters follow a specific keyword. If the string length exceeds the specified length, the string is truncated to the specified length.
  1. SELECT RPAD('hi', 5, 'xy') FROM (VALUES(1));
  2. +-------------------------+
  3. | EXPR$0 |
  4. +-------------------------+
  5. | hixyx |
  6. +-------------------------+
  7. 1 row selected (0.107 seconds)
  • RTRIM

Syntax: RTRIM(string1, string2)
The RTRIM function removes all the characters that are contained in the specified set (string2) from the right side of the input string (string1).

  1. SELECT RTRIM('testxxzx', 'xyz') from (VALUES(1));
  2. +--------------------+
  3. | EXPR$0 |
  4. +--------------------+
  5. | tes |
  6. +--------------------+
  7. 1 row selected (0.102 seconds)
  • STRPOS

Syntax: STRPOS(string, substring)
The STRPOS function returns the position of a substring in a string.

  1. SELECT STRPOS('high', 'ig') FROM (VALUES(1));
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | 2 |
  6. +------------+
  7. 1 row selected (0.22 seconds)
  • SUBSTR

Syntax: SUBSTR(string, x, y)
The SUBSTR function returns the substring from the x to x+y position in a string. The y argument is optional.

  1. SELECT SUBSTR('China Beijing', 7) FROM (VALUES(1));
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | Beijing |
  6. +------------+
  7. 1 row selected (0.134 seconds)
  8. SELECT SUBSTR('China Beijing', 3, 2) FROM (VALUES(1));
  9. +------------+
  10. | EXPR$0 |
  11. +------------+
  12. | in |
  13. +------------+
  14. 1 row selected (0.129 seconds)
  • TRIM

Syntax: TRIM ([leading | trailing | both] [string1] from string2)
The TRIM function removes all the characters that are contained in the specified set (string1) from the left side or the right side of a string (string2).

  1. SELECT TRIM(trailing 'A' from 'AABBAA') FROM (VALUES(1));
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | AABB |
  6. +------------+
  7. 1 row selected (0.172 seconds)
  8. SELECT TRIM(both 'A' from 'AABBAA') FROM (VALUES(1));
  9. +---------------+
  10. | EXPR$0 |
  11. +---------------+
  12. | BB |
  13. +---------------+
  14. 1 row selected (0.104 seconds)
  15. SELECT TRIM(leading 'A' from 'AABBAA') FROM (VALUES(1));
  16. +-----------------+
  17. | EXPR$0 |
  18. +-----------------+
  19. | BBAA |
  20. +-----------------+
  21. 1 row selected (0.101 seconds)
  • UPPER

Syntax: UPPER(string)
The UPPER function converts lowercase characters in a string to uppercase characters.

  1. SELECT UPPER('china beijing') FROM (VALUES(1));
  2. +---------------+
  3. | EXPR$0 |
  4. +---------------+
  5. | CHINA BEIJING |
  6. +---------------+
  7. 1 row selected (0.081 seconds)

5. Timestamp functions

The following table lists the timestamp functions that are supported by TSQL.

Function Return type Description Example
now() TIMESTAMP Returns the current timestamp. now()
CURRENT_TIMESTAMP TIMESTAMP Returns the current timestamp. CURRENT_TIMESTAMP
CURRENT_DATE DATE Returns the current date. CURRENT_DATE
CURRENT_TIME TIME Returns current time. The returned value excludes the date information. CURRENT_TIME
EXTRACT(component FROM timestamp/date/time) INT Extracts a year, month, day, hour, minute, or second component from a specified timestamp, date, or time. EXTRACT(day from `timestamp`
tumble(timestamp, interval) TIMESTAMP Returns the lower boundary of a tumbling window that contains the specified timestamp. tumble(`timestamp`, interval ‘5’ minute)
date_diff(timestamp, interval) TIMESTAMP Returns a new timestamp after the specified interval is subtracted from a timestamp. date_diff(timestamp, interval ‘5’ minute)
date_add(timestamp, interval) TIMESTAMP Returns a new timestamp after the specified interval is added to a timestamp. date_add(timestamp, interval ‘5’ minute)

The following examples are used to describe how to use the timestamp functions.

  1. SELECT CURRENT_DATE FROM (VALUES(1));
  2. +---------------+
  3. | CURRENT_DATE |
  4. +---------------+
  5. | 2019-11-27 |
  6. +---------------+
  1. SELECT EXTRACT(hour FROM TIME '17:12:28.5') FROM (VALUES(1));
  2. +---------+
  3. | EXPR$0 |
  4. +---------+
  5. | 17 |
  6. +---------+
  1. SELECT EXTRACT(SECOND FROM TIMESTAMP '2001-02-16 20:38:40') FROM (VALUES(1));
  2. +---------+
  3. | EXPR$0 |
  4. +---------+
  5. | 40.0 |
  6. +---------+
  1. SELECT DATE_DIFF(TIMESTAMP '2001-02-16 20:38:40', interval '5' minute) FROM (VALUES(1));
  2. +------------------------+
  3. | EXPR$0 |
  4. +------------------------+
  5. | 2001-02-16 20:33:40.0 |
  6. +------------------------+
  1. SELECT DATE_ADD(TIMESTAMP '2001-02-16 20:38:40', interval '5' minute) FROM (VALUES(1));
  2. +------------------------+
  3. | EXPR$0 |
  4. +------------------------+
  5. | 2001-02-16 20:43:40.0 |
  6. +------------------------+
  1. SELECT tumble(TIMESTAMP '2001-02-16 20:38:40', interval '5' minute) FROM (VALUES(1));
  2. +------------------------+
  3. | EXPR$0 |
  4. +------------------------+
  5. | 2001-02-16 20:35:00.0 |
  6. +------------------------+

6. Data type conversion functions

6.1 CAST

The CAST function converts the value of a specified expression from one data type to another data type. A single value can be obtained based on the specified expression.

  • Syntax

`

  1. CAST (<expression> AS <data type>)
  • Syntax element: expression

The expression element specifies one or more values whose data types are to be converted. The specified expression consists of operators and SQL functions.

  • Syntax element: data type

The data type element specifies the target data type, such as INT or DATE.

This topic provides the following examples. In these examples, a string is converted to a number, a number is converted to a string, and a number is converted from one data type to another data type, respectively.

  1. SELECT CAST(456 as VARCHAR(3)) FROM (VALUES(1));
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | 456 |
  6. +------------+
  7. 1 row selected (0.08 seconds)
  8. SELECT CAST(456 as CHAR(3)) FROM (VALUES(1));
  9. +------------+
  10. | EXPR$0 |
  11. +------------+
  12. | 456 |
  13. +------------+
  14. 1 row selected (0.093 seconds)

6.2 Convert timestamp, date, and time data types

TSQL supports the following date and time formats:

  • 2008-12-15
  • 22:55:55.123…

If the date and time use other formats, use data type conversion functions to perform the following operations:

  • Convert values of the TIMESTAMP, DATE, TIME, INT, FLOAT, or DOUBLE data type to strings of the VARCHAR data type.
  • Convert strings to values of the DATE data type.
  • Convert strings to values of the NUMBER data type.

The following table lists the data type conversion functions that you can use in TSQL queries.

Function Return type
TO_CHAR(expression, format) VARCHAR
TO_DATE(expression, format) DATE
TO_TIMESTAMP(VARCHAR, format) TIMESTAMP
TO_TIMESTAMP(DOUBLE) TIMESTAMP

Format symbols for date and time conversion

The following table lists the Joda-Time formatting symbols that are used for date and time conversion.

Symbol Meaning Presentation Example
G era text AD
C century of era (>=0) number 20
Y year of era (>=0) year 1996
x weekyear year 1996
w week of weekyear number 27
e day of week number 2
E day of week text Tuesday; Tue
y year year 1996
D day of year number 189
M month of year month July; Jul; 07
d day of month number 10
a halfday of day text PM
K hour of halfday (0~11) number 0
h clockhour of halfday (1~12) number 12
H hour of day (0~23) number 0
k clockhour of day (1~24) number 24
m minute of hour number 30
s second of minute number 55
S fraction of second number 978
z time zone text Pacific Standard Time; PST
Z time zone offset/id Zone -0800; -08:00; America/Los_Angeles
single quotation mark, escape for text delimiter Literal
  • TO_CHAR example:

The TO_CHAR function converts a number, date, time, or timestamp expression to a string.

  1. SELECT TO_CHAR(1256.789383, '#,###.###') FROM (VALUES(1));
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | 1,256.789 |
  6. +------------+
  7. 1 row selected (1.767 seconds)
  8. SELECT TO_CHAR(125677.4567, '#,###.###') FROM (VALUES(1));
  9. +--------------+
  10. | EXPR$0 |
  11. +--------------+
  12. | 125,677.457 |
  13. +--------------+
  14. 1 row selected (0.083 seconds)
  15. SELECT TO_CHAR((CAST('2008-2-23' AS DATE)), 'yyyy-MMM-dd') FROM (VALUES(1));
  16. +--------------+
  17. | EXPR$0 |
  18. +--------------+
  19. | 2008-Feb-23 |
  20. +--------------+
  21. 1 row selected (0.166 seconds)
  22. SELECT TO_CHAR(CAST('12:20:30' AS TIME), 'HH mm ss') FROM (VALUES(1));
  23. +------------+
  24. | EXPR$0 |
  25. +------------+
  26. | 12 20 30 |
  27. +------------+
  28. 1 row selected (0.07 seconds)
  29. SELECT TO_CHAR(CAST('2015-2-23 12:00:00' AS TIMESTAMP), 'yyyy MMM dd HH:mm:ss') FROM (VALUES(1));
  30. +-----------------------+
  31. | EXPR$0 |
  32. +-----------------------+
  33. | 2015 Feb 23 12:00:00 |
  34. +-----------------------+
  35. 1 row selected (0.142 seconds)
  • TO_DATE examples:The first example converts a string to a date. The second example extracts the year component from a date to verify that TSQL recognizes the date as a value of the DATE type.
  1. SELECT TO_DATE('2015-FEB-23', 'yyyy-MMM-dd') FROM (VALUES(1));
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | 2015-02-23 |
  6. +------------+
  7. 1 row selected (0.077 seconds)
  8. SELECT EXTRACT(year from mydate) `extracted year` FROM (SELECT TO_DATE('2015-FEB-23', 'yyyy-MMM-dd') AS mydate FROM (VALUES(1)));
  9. +------------+
  10. | myyear |
  11. +------------+
  12. | 2015 |
  13. +------------+
  14. 1 row selected (0.128 seconds)

The following example converts a Unix timestamp to a date.

  1. SELECT TO_DATE(1427849046000) FROM (VALUES(1));
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | 2015-04-01 |
  6. +------------+
  7. 1 row selected (0.082 seconds)
  • TO_TIME example:The TO_TIME function converts a string to a time value.
  1. SELECT TO_TIME('12:20:30', 'HH:mm:ss') FROM (VALUES(1));
  2. +------------+
  3. | EXPR$0 |
  4. +------------+
  5. | 12:20:30 |
  6. +------------+
  7. 1 row selected (0.067 seconds)
  8. SELECT to_time(82855000) FROM (VALUES(1));
  9. +------------+
  10. | EXPR$0 |
  11. +------------+
  12. | 23:00:55 |
  13. +------------+
  14. 1 row selected (0.086 seconds)
  • TO_TIMESTAMP example:

The TO_TIMESTAMP function converts a date to a timestamp.

  1. SELECT TO_TIMESTAMP('2008-2-23 12:00:00', 'yyyy-MM-dd HH:mm:ss') FROM (VALUES(1));
  2. +------------------------+
  3. | EXPR$0 |
  4. +------------------------+
  5. | 2008-02-23 12:00:00.0 |
  6. +------------------------+
  7. 1 row selected (0.126 seconds)

The following example converts the Unix time to a timestamp.

  1. SELECT TO_TIMESTAMP(1427936330) FROM (VALUES(1));
  2. +------------------------+
  3. | EXPR$0 |
  4. +------------------------+
  5. | 2015-04-01 17:58:50.0 |
  6. +------------------------+
  7. 1 row selected (0.114 seconds)

The following example converts a Coordinated Universal Time (UTC) date to a timestamp that includes a time zone offset in its value.

  1. SELECT TO_TIMESTAMP('2015-03-30 20:49:59.0 UTC', 'YYYY-MM-dd HH:mm:ss.s z') AS Original,
  2. TO_CHAR(TO_TIMESTAMP('2015-03-30 20:49:59.0 UTC', 'YYYY-MM-dd HH:mm:ss.s z'), 'z') AS New_TZ
  3. FROM (VALUES(1));
  4. +------------------------+---------+
  5. | Original | New_TZ |
  6. +------------------------+---------+
  7. | 2015-03-30 20:49:00.0 | UTC |
  8. +------------------------+---------+
  9. 1 row selected (0.148 seconds)