Name | Operand Type | Result Type | Description |
c(expr) | any | c | Converts any value to a c string |
char(expr) | any | char | Converts any value to a char string |
date(expr) | c, char, text, varchar | date | Converts a c, char, varchar, or text string to internal date representation |
decimal(expr, 1 < p <31 0 < s <p) | c, char, varchar, text, float, money, integer(1), smallint, integer | decimal | Returns the decimal representation of the argument string |
dow(expr) | date | c | Converts an absolute date into its day of week (for example, 'Mon,' 'Tue'); the result length is 3 |
float4(expr) | c, char, varchar, text, float, money, integer(1), smallint, integer | float4 | Converts the specified expression to float4 |
float8(expr) | c, char, varchar, text, float, money, integer(1), smallint, integer | float | Converts the specified expression to float |
hex(expr) | varchar, c, char, text | varchar | Returns the hexadecimal representation of the argument string; the length of the result is twice the length of the argument, because the hexadecimal equivalent of each character requires two bytes For example, hex('A') returns '61' (ASCII) or 'C1' (EBCDIC). |
int1(expr) | c, char, varchar, text, float, money, integer(1), smallint, integer | integer1 | Converts the specified expression to integer1; floating point values are truncated |
int2(expr) | c, char, varchar, text, float, money, integer(1), smallint, integer | smallint | Converts the specified expression to smallint; floating point values are truncated |
int4(expr) | c, char, varchar, text, float, money, integer(1), smallint, integer | integer | Converts the specified expression to integer; floating point values are truncated |
money(expr) | c, char, varchar, text, float, integer(1), smallint, integer, | money | Converts the specified expression to internal money representation; rounds floating point values, if necessary |
text(expr) | any | text | Converts any value to a text string; this function removes any trailing blanks from c or char string expressions |
varchar(expr) | any | varchar | Converts any value to a varchar string; this function removes any trailing blanks from c or char string expressions |
Numeric Function Name | Operand Type | Result Type | Description |
ABS(n) | all numeric types and money | same as n | Absolute value of n. |
ACOS(n) | all numeric types | float | Arccosine of cosine value n |
ASIN(n) | all numeric types | float | Arcsine value of sine value n |
ATAN(n) | all numeric types | float | Arctangent of n; returns a value from (-pi/2) to pi/2. |
ATAN2 (x, y) | all numeric types | float | Arctangent of angle defined by coordinate pair (x, y) |
CEIL(n) CEILING(n) | all numeric types | decimal | Returns the smallest integer greater than or equal to the specified numeric expression. |
COS(n) | all numeric types | float | Cosine of n; returns a value from -1 to 1. |
EXP(n) | all numeric types and money | float | Exponential of n. |
FLOOR(n) | all numeric types | decimal | Returns the largest integer less than, or equal to, the specified numeric expression. |
LOG(n) LN(n) | all numeric types and money | float | Natural logarithm of n. |
MOD(n,b) | integer, smallint, integer1, decimal | same as b | n modulo b. The result is the same data type as b. Decimal values are truncated. |
PI() | None | float | Value of pi (ratio of the circumference of a circle to its diameter) |
ROUND(n,i) | all numeric types | decimal | Rounds value at the i'th place right or left of the decimal, depending on whether i is greater or less than 0. |
SIGN(n) | all numeric types | integer | -1 if n < 0, 0 if n = 0, +1 if n > 0 |
SIN(n) | all numeric types | float | Sine of n; returns a value from -1 to 1. |
SQRT(n) | all numeric types and money | float | Square root of n. |
TAN(n) | all numeric types | float | Tangent value of angle n |
String Function Name | Result Type | Description |
ASCII(v1) | any character type | Returns the character equivalent of the value v1, which is an expression of either character or numeric type. |
CHAREXTRACT(c1,n) | varchar or nchar | Returns the nth character or code point of c1. If n is larger than the length of the string, the result is a blank character. It does not support long varchar or long nvarchar arguments. |
CHARACTER_LENGTH(c1) | integer | Returns the number of characters in c1 without trimming blanks, as is done by the LENGTH() function. This function does not support nchar and nvarchar arguments. |
CHR(n) | character | Converts integer into corresponding ASCII code. If n is greater than 255, the conversion is performed on n mod 256. |
CONCAT(c1,c2) | any character or Unicode data type, byte | Concatenates one string to another. The result size is the sum of the sizes of the two arguments. If the result is a c or char string, it is padded with blanks to achieve the proper length. To determine the data type results of concatenating strings, see the table regarding results of string concatenation. This function does not support long nvarchar arguments. |
LEFT(c1,len) | any character or Unicode data type | Returns the leftmost len characters of c1. If the result is a fixed-length c or char string, it is the same length as c1, padded with blanks. The result format is the same as c1. This function does not support long nvarchar arguments. |
LENGTH(c1) | smallint (for long varchar, returns 4-byte integer) | If c1 is a fixed-length c or char string, returns the length of c1 without trailing blanks. If c1 is a variable-length string, returns the number of characters actually in c1. |
LOCATE(c1,c2) | smallint | Returns the location of the first occurrence of c2 within c1, including trailing blanks from c2. The location is in the range 1 to size(c1). If c2 is not found, the function returns size(c1) + 1. The function size() is described below, in this table. If c1 and c2 are different string data types, c2 is coerced into the c1 data type. This function does not support long varchar or long nvarchar arguments. |
LOWERCASE(c1) or LOWER(c1) | any character or Unicode data type | Converts all upper case characters in c1 to lower case. |
LTRIM(expr) | any character data type | Returns character expression with leading blanks removed. |
OCTET_LENGTH(c1) | integer | Returns the number of 8-bit octets (bytes) in c1 without trimming blanks, as is done by the LENGTH() function. |
PAD(c1) | text, varchar, or nvarchar | Returns c1 with trailing blanks appended to c1. For example, if c1 is a varchar string that could hold 50 characters but only has two characters, then PAD(c1) appends 48 trailing blanks to c1 to form the result. |
RIGHT(c1,len) | any character or Unicode data type | Returns the rightmost len characters of c1. Trailing blanks are not removed first. If c1 is a fixed-length character string, the result is padded to the same length as c1. If c1 is a variable-length character string, no padding occurs. The result format is the same as c1. This function does not support long nvarchar arguments. |
RTRIM(expr) | any character data type | Returns character expression with trailing blanks removed. |
SHIFT(c1,nshift) | any character or Unicode data type | Shifts the string nshift places to the right if nshift > 0 and to the left if nshift < 0. If c1 is a fixed-length character string, the result is padded with blanks to the length of c1. If c1 is a variable-length character string, no padding occurs. The result format is the same as c1. This function does not support long varchar or long nvarchar arguments. |
SIZE(c1) | smallint | Returns the declared size of c1 without removal of trailing blanks. |
SOUNDEX(c1) | any character data type | Returns a c1 four-character field that can be used to find similar sounding strings. For example, SMITH and SMYTHE produce the same SOUNDEX code. If there are less than three characters, the result is padded by trailing zero(s). If there are more than three characters, the result is achieved by dropping the rightmost digits. This function is useful for finding like-sounding strings quickly. A list of similar sounding strings can be shown in a search list rather than just the next strings in the index. This function does not support long varchar or any Unicode arguments. |
SQUEEZE(c1) | text or varchar | Compresses white space. White space is defined as any sequence of blanks, null characters, newlines (line feeds), carriage returns, horizontal tabs and form feeds (vertical tabs). Trims white space from the beginning and end of the string, and replaces all other white space with single blanks. This function is useful for comparisons. The value for c1 must be a string of variable‑length character string data type (not fixed-length character data type). The result is the same length as the argument. This function does not support long varchar or long nvarchar arguments. |
TRIM(c1) | text or varchar | Returns c1 without trailing blanks. The result has the same length as c1. This function does not support long varchar or long nvarchar arguments. |
UPPERCASE(c1) or UPPER(c1) | any character data type | Converts all lower case characters in c1 to upper case. |
1st String | 2nd String | Trim Blanks | Result Type | |
from 1st? | from 2nd? | |||
c | c | Yes | -- | C |
c | text | Yes | -- | C |
c | char | Yes | -- | C |
c | varchar | Yes | -- | C |
text | c | No | -- | C |
char | c | Yes | -- | C |
varchar | c | No | -- | C |
text | text | No | No | text |
text | char | No | Yes | text |
text | varchar | No | No | text |
char | text | Yes | No | text |
varchar | text | No | No | text |
char | char | No | -- | char |
char | varchar | No | -- | char |
varchar | char | No | -- | char |
varchar | varchar | No | No | varchar |
nchar | nchar | No | No | nchar |
nchar | nvarchar | No | No | nchar |
nvarchar | nchar | No | No | nchar |
nvarchar | nvarchar | No | No | nvarchar |
Date Portion | How Specified |
Second | SECOND, SECONDS, SES, SECS |
Minute | MINUTE, MINUTES, MIN, MINS |
Hour | HOUR, HOURS, HR, HRS |
Day | DAY, DAYS |
Week | WEEK, WEEKS, WK, WKS |
ISO-Week | ISO-WEEK, ISO-WK |
Month | MONTH, MONTHS, MO, MOS |
Quarter | QUARTER, QUARTERS, QTR, QTRS |
Year | YEAR, YEARS, YR, YRS |
Date Function Name | Format (Result) | Description |
DATE_TRUNC(unit,date) | date | Returns a date value truncated to the specified unit. |
DATE_PART(unit,date) | integer | Returns an integer containing the specified (unit) component of the input date. |
DATE_GMT(date) | any character data type | Converts an absolute date into the Greenwich Mean Time character equivalent with the format yyyy_mm_dd hh:mm:ss GMT. If the absolute date does not include a time, the time portion of the result is returned as 00:00:00. For example, the query: SELECT DATE_GMT('1-1-98 10:13 PM PST') returns the following value: 1998_01_01 06:13:00 GMT while the query: SELECT DATE_GMT(‘1-1-1998’) returns: 1998_01_01 00:00:00 GMT |
GMT_TIMESTAMP(s) | any character data type | Returns a twenty-three-character string giving the date s seconds after January 1, 1970 GMT. The output format is ‘yyyy_mm_dd hh:mm:ss GMT’. For example, the query: SELECT (GMT_TIMESTAMP (1234567890)) returns the following value: 2009_02_13 23:31:30 GMT while the query: (II_TIMEZONE_NAME = AUSTRALIA-QUEENSLAND) SELECT date(GMT_TIMESTAMP (1234567890)) returns: 14-feb-2009 09:31:30 |
INTERVAL (unit,date_interval) | float | Converts a date interval into a floating-point constant expressed in the unit of measurement specified by unit. The interval function assumes that there are 30.436875 days per month and 365.2425 days per year when using the mos, qtrs, and yrs specifications. For example, the query: SELECT(INTERVAL(‘days’, ‘5 years’)) returns the following value: 1826.213 |
ISDST(date) | integer | Returns 1 if date falls within Daylight Saving Time for the session timezone, else 0. |
_DATE(s) | any character data type | Returns a nine-character string giving the date s seconds after January 1, 1970 GMT. The output format is dd-mmm-yy. For example, the query: SELECT _DATE(123456) returns the following value: 2-jan-70 Note that this function formats a leading space for day values less than 10. |
_DATE4(s) | any character data type | Returns an eleven-character string giving the date s seconds after January 1, 1970 GMT. The output format is controlled by the II_DATE_FORMAT setting. For example, with II_DATE_FORMAT set to US, the query: SELECT _DATE4(123456) returns the following value: 02-jan-1970 while with II_DATE_FORMAT set to MULTINATIONAL, the query: SELECT _DATE4(123456) returns the following value: 02/01/1970 |
_TIME(s) | any character data type | Returns a five-character string giving the time s seconds after January 1, 1970 GMT, which is then adjusted for your local time zone. The output format is hh:mm (seconds are truncated). For example, the query: SELECT _TIME(123456) returns the value 02:17 for the NA-PACIFIC time zone. |
Date Column | Day of Week | Week | ISO-Week |
02-jan-1998 | Fri | 0 | 1 |
04-jan-1998 | Sun | 0 | 1 |
02-jan-1999 | Sat | 0 | 53 |
04-jan-1999 | Mon | 1 | 1 |
02-jan-2000 | Sun | 0 | 52 |
04-jan-2000 | Tue | 1 | 1 |
02-jan-2001 | Tue | 1 | 1 |
04-jan-2001 | Thu | 1 | 1 |
Col1 | Col2 | Col3 | Col4 |
-920527466 | 1526341860 | -920527466 | -1447292811 |