Data Type Casting Functions date2string ( date_expression ) Returns a date as a string in YYYY-MM-DD format. time2string ( time_expression ) Returns a time as a string in HH:MM:SS.FFF format. timeTZ2string ( timeTZ_expression ) Returns a time with the time zone as a string in HH:MM:SS.FFF +HHMM or HH:MM:SS.FFFFFFF -HHMM format. For example, -05:30 means a timezone of GMT minus 5 hours and 30 minutes timestamp2string ( timestamp_expression ) Returns a timestamp as a string in YYYY-MM-DD HH:MM:SS.FFFFFFF format. timestampTZ2string ( timestamp_time_zone_expression ) Returns a timestamp with the time zone as a string in YYYY-MM-DD HH:MM:SS.FFFFFFF +HHMM or YYYY-MM-DD HH:MM:SS.FFF -HHMM format. DTinterval2string ( date_time_interval_expression ) Returns a date time interval as a string in DDDD HH:MM:SS.FFFFFFF or -DDDD HH:MM:SS.FFF format. DTinterval2stringAsTime ( date_time_interval_expression ) Returns a date time interval as a string in HHHH:MM:SS.FFFFFFF or HH:MM:SS.FFF format. Days are converted to hours. int2DTinterval ( integer_expression , string_expression ) Converts an integer to a date time interval. "String_expression" specifies what "integer_expression" represents: "ns" = nanoseconds, "s" = seconds (default), "m" = minutes, "h" = hours, "d" = days. Example: int2DTinterval (1020,"h") Result: 42 days 12 hours Example: int2DTinterval (1020,"s") Result: 17 minutes mapNumberToLetter ( string_expression , integer_expression ) Adds "integer_expression" to "string_expression". Example: mapNumberToLetter ( 'a' , 1 ) Result: b nullif ( string_expression1 , string_expression2 ) Returns null if "string_expression1" equals "string_expression2" (case-insensitive), otherwise returns "string_expression1". mod ( integer_expression1 , integer_expression2 ) Returns an integer value representing the remainder (modulo) of "integer_expression1" / "integer_expression2". power ( numeric_expression1 , numeric_expression2 ) Returns "numeric_expression1" raised to the power of "numeric_expression2". Example: power ( 3 , 2 ) Result: 9 int2YMinterval ( integer_expression , string_expression ) Converts "integer_expression" to a year month interval. "String_expression" specifies what "integer_expression" represents: "y" = years, "m" = months (default). YMinterval2string ( year_month_interval_expression ) Returns "year_month_interval_expression" as a string in (YY MM) or -(YY MM) format. number2string ( numeric_expression ) Converts "numeric_expression" to a string, using the %g format specifier (C/C++ syntax). string2date ( string_expression ) Returns "string_expression" as a date in YYYY-MM-DD format. Returns "string_expression" as a Year Month Interval in [-]YY MM format. string2YMinterval ( string_expression ) Returns "string_expression" as a date time interval in [-]DD HH:MM[:SS[.FFF]] format. string2DTinterval ( string_expression ) string2time ( string_expression ) Returns "string_expression" as a time in HH:MM:SS.FFFFFFF format. string2timestamp ( string_expression ) Returns "string_expression" as a timestamp in YYYY-MM-DD [T|t|[white space]+] HH:MM:SS.FFFFFFF format. string2timestampTZ ( string_expression ) Returns "string_expression" in YYYY-MM-DD HH:MM:SS.FFFFFFF +HHMM or YYYY-MM-DD [T|t] HH:MM:SS.FFF -HHMM format. string2double ( string_expression ) Returns a floating point number. "String_expression" has the following form: "[whitespace] [sign] [digits] [digits] [ {d|D|e|E }[sign]digits]" string2int64 ( string_expression ) Returns a long integer. "String_expression" has the following form: "[whitespace] [{+|-}] [digits]" string2int32 ( string_expression ) Returns an integer. "String_expression" has the following form: "[whitespace] [{+|-}] [digits]" date2timestamp ( date_expression ) Converts "date_expression" to a timestamp. The time part of the timestamp will equal zero. timestamp2date ( timestamp_expression ) Converts "timestamp_expression" to a date. The time part of the timestamp will be ignored. timestamp2timestampTZ ( timestamp_expression ) Converts "timestamp_expression" to a timestamp with a time zone. The displacement part of the timestamp with the time zone will be zero. timestampTZ2timestamp ( timestamp_time_zone_expression ) Converts "timestamp_time_zone_expression" to a timestamp. The displacement part of the timestamp with the time zone will be ignored. date2timestampTZ ( date_expression ) Converts "date_expression" to a timestamp with a time zone. The time and time zone parts of the timestamp will equal zero. timestampTZ2date ( timestamp_time_zone_expression ) Converts "timestamp_time_zone_expression" to a date. The time and time zone parts of the timestamp will be ignored. _add_days ( timestamp_expression , integer_expression ) Returns the datetime resulting from adding "integer_expression" days to "timestamp_expression". Example: _add_days ( 2007-01-14 00:00:00.000 , 3 ) Result: 2007-01-17 00:00:00.000 _add_months ( timestamp_expression , integer_expression ) Returns the datetime resulting from adding "integer_expression" months to "timestamp_expression". _add_years ( timestamp_expression , integer_expression ) Returns the datetime resulting from adding "integer_expression" years to "timestamp_expression". _age ( timestamp_expression ) Returns a number by subtracting "timestamp_expression" from today's date. Example: _age ([Query1].[Date]), where [Query1].[Date] is March 2, 2004, and today is July 8, 2009 Result: 50,406, where 5 is the number of years, 04 is the number of months, and 06 is the number of days. _day_of_week ( timestamp_expression , integer_expression ) Returns the day of the week (between 1 and 7) for "timestamp_expression" where "integer_expression" indicates which day of that week is day 1. To determine "integer_expression", choose the day of the week and count from Monday; for example, if you choose Wednesday, "integer_expression" would be 3 because Wednesday is the third day from Monday. Example: _day_of_week ( 2009-01-01 , 7 ), where 7 means that Sunday is the first day of the week. Result: 5 _day_of_year ( timestamp_expression ) Returns the ordinal for the day of the year in "timestamp_ expression" (1 to 366). Also known as Julian day. _days_between ( timestamp_expression1 , timestamp_expression2 ) Returns a positive or negative number representing the number of days between "timestamp_expression1" and "timestamp_expression2". If "timestamp_expression1" < "timestamp_expression2", the result will be a negative number. _days_to_end_of_month ( timestamp_expression ) Returns a number representing the number of days remaining in the month represented by "timestamp_expression". _first_of_month ( timestamp_expression ) Returns a datetime that is the first day of the month represented by "timestamp_expression". Example: _first_of_month ( 2009-05-04 00:00:00.000 ) Result: Returns 2009-05-01 00:00:00.000 Example: _first_of_month (current_date) Result: Returns Jul 1, 2009 if the current date is July 30, 2009. _last_of_month ( timestamp_expression ) Returns a datetime that is the last day of the month represented by "timestamp_expression". _make_timestamp ( integer_expression1 , integer_expression2 , integer_expression3 ) Returns a timestamp constructed from "integer_expression1" (the year), "integer_expression2" (the month), and "integer_expression3" (the day). The time portion defaults to 00:00:00.000 . _months_between ( timestamp_expression1 , timestamp_expression2 ) Returns a positive or negative number representing the number of months between "timestamp_expression1" and "timestamp_expression2". If "timestamp_expression1" < "timestamp_expression2", the result will be a negative number. _week_of_year ( timestamp_expression ) Returns the week number (1-53) of the year for "timestamp_expression". According to the ISO 8601, week 1 of the year is the first week to contain a Thursday, which is equivalent to the first week containing January 4th. A week starts on a Monday (day 1) and ends on a Sunday (day 7). _years_between ( timestamp_expression1 , timestamp_expression2 ) Returns a positive or negative integer representing the number of years between "timestamp_expression1" and "timestamp_expression2". If "timestamp_expression1" < "timestamp_expression2", a negative value is returned. _ymdint_between ( timestamp_expression1 , timestamp_expression2 ) Returns a number representing the difference between "timestamp_expression1" and "timestamp_expression2". This value has the form YYMMDD, where YY represents the number of years, MM represents the number of months, and DD represents the number of days. Example: _ymdint_between ( [Query1].[Date (close date)] , [Query1].[Date (ship date)] ), where [Query1].[Date (close date)] is February 20, 2004, and [Query1].[Date (ship date)] is January 19, 2004. Result: 101, where 1 is the number of months and 01 is the number of days. abs ( numeric_expression ) Returns the absolute value of "numeric_expression". If "numeric_expression" is negative, a positive value is returned. ceiling ( numeric_expression ) Returns the smallest integer that is greater than or equal to "numeric_expression". exp ( numeric_expression ) Returns the constant 'e' raised to the power of "numeric_expression". The constant 'e' is the base of the natural logarithm. Example: exp ( 2 ) Result: 7.389056 floor ( numeric_expression ) Returns the largest integer that is less than or equal to "numeric_expression". ln ( numeric_expression ) Returns the natural logarithm of "numeric_expression". round ( numeric_expression , integer_expression ) Returns "numeric_expression" rounded to the nearest value with "integer_expression" significant digits to the right of the decimal point. If "integer_expression" is negative, "numeric_expression" is rounded to the nearest absolute value with "integer_expression" significant digits to the left of the decimal point. Rounding takes place before data formatting is applied. Example: round (125, -1) Result: 130 sqrt ( numeric_expression ) Returns the square root of "numeric_expression". "Numeric_expression" must not be a negative value. character_length ( string_expression ) Returns the number of characters in "string_expression". extract ( date_part_expression , datetime_expression ) Returns an integer representing the value of "date_part_expression" in "datetime_expression". "Date_part_expression" could be the year, month, day, hour, minute, or second. Example: extract ( 'year' ,string2timestamp( '2003-03-03 16:40:15.535' )) Result: 2003 Example: extract ( 'hour' ,string2timestamp( '2003-03-03 16:40:15.535' )) Result: 16 lower ( string_expression ) Returns "string_expression" with all uppercase characters converted to lowercase. This function appears in the Bursted Sales Performance Report sample report in the GO Data Warehouse (query) package. octet_length ( string_expression ) Returns the number of bytes in "string_expression". position ( string_expression1 , string_expression2 ) Returns the integer value representing the starting position of "string_expression1" in "string_expression2". Returns 0 if "string_expression1" is not found. substring ( string_expression , integer_expression1 , integer_expression2 ) Returns the substring of "string_expression" that starts at position "integer_expression1" for "integer_expression2" characters or to the end of "string_expression" if "integer_expression2" is -1. The first character in "string_expression" is at position 1. substring ( [Sales (analysis)].[Sales staff].[Sales staff].[Sales staff].[Position code], 3 , 5 ) Result: Returns characters 3 to 7 of the position codes. trim ( trim_what_expression , match_character_expression , string_expression ) Returns "string_expression" trimmed of any leading and trailing blanks or trimmed of the character specified by "match_character_expression". "Trim_what_expression" may be "leading", "trailing", or "both" (default). "Match_character_expression" can be an empty string to trim blanks or can specify a character to be trimmed. upper ( string_expression ) Returns "string_expression" with all lowercase characters converted to uppercase. status ( expression ) Returns the status of "expression". Possible values are: 0 - OK, 1 - null, 2 - not available, 4 - divide by zero, 8 - overflow, 16 - security, 32 - error, 64 - new, 128 - sample, 256 - pending.