Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Functions that convert between numbers, dates, and timestamps and their string representations. Use data type formatting functions to:
- Format numbers for display by converting numeric values to strings with custom patterns.
- Parse date and time strings by converting text input into typed date or timestamp values.
- Generate readable output by formatting timestamps and intervals into locale-friendly strings.
Considerations
- NULL handling: All formatting functions return NULL when any argument is NULL.
- Pattern syntax: Date and time formatting uses TO_CHAR patterns (such as
YYYY-MM-DD). Numeric formatting uses FORMAT_NUMBER patterns (such as #,###.0).
Format as String
Convert typed values to formatted strings:
- FORMAT_NUMBER — Convert a number to a string using a format pattern.
- TO_CHAR — Convert a timestamp or interval to a string using a format pattern.
Parse from String
Convert strings to typed date and time values:
- TO_DATE — Convert a string to a date using a format pattern.
- TO_TIMESTAMP — Convert a string to a timestamp using a format pattern.
Examples
Format a number for display
Convert a numeric value to a string with thousands separators and decimal places.
1SELECT format_number(1234567.89, '#,##0.00') AS formatted_amount;
Returns '1,234,567.89'.
Parse a date string
Convert a text date into a typed date value for comparison or arithmetic.
1SELECT to_date('05 Dec 2000', 'DD Mon YYYY') AS parsed_date;
Returns 2000-12-05.
Format a timestamp
Convert the current timestamp into a human-readable string.
1SELECT to_char(current_timestamp, 'FMDay, FMDD Mon YYYY HH12:MI:SS AM') AS readable_ts;
Returns a string such as 'Tuesday, 6 May 2025 03:22:45 PM'.
Related Documentation