Tabular IQ
Back to Function Index

RIGHT()

Overview

RIGHT() extracts a specified number of characters from the end of a string. If the specified length exceeds the string's length, the entire string is returned. This function is useful for extracting portions of strings from the right side, such as file extensions, suffixes, or end portions of text.

Function Format

RIGHT(string, length)

Return Value

RIGHT() returns a character string

Examples


// Extracting from the end
RIGHT("APPLES AND ORANGES", 7) = "ORANGES"
RIGHT("APPLES AND ORANGES", 11) = "AND ORANGES"

// Length exceeds string length
RIGHT("APPLES AND ORANGES", 20) = "APPLES AND ORANGES"

// Edge cases
RIGHT("HELLO", 0) = ""              // Zero length
RIGHT("HELLO", 5) = "HELLO"         // Exact length
RIGHT("", 5) = ""                   // Empty string

Notes

  • Important behaviors:
    • Extracts characters from the right end of the string
    • Returns entire string if length exceeds string length
    • Returns empty string if length is 0
    • Returns empty string if input string is empty
    • Length must be a non-negative number
  • Common use cases include:
    • Extracting file extensions
    • Getting end portions of text
    • String truncation
    • Data extraction
    • Format standardization
  • The function is useful for:
    • Right-side string extraction
    • Text manipulation
    • Data processing
    • Format handling

See Also