---
title: "rtrim function in Strata | Oplema"
description: "Remove spaces from the end of text, leaving the rest of the value unchanged. For example, rtrim('  hello  ') returns '  hello'."
url: "https://oplema.com/docs/strata/functions/rtrim"
updated: "2026-11-04"
---

# rtrim

Remove spaces from the end of text. Pass a second argument to remove those characters instead.

## Try an expression

In [Formula](https://oplema.com/docs/strata/prep/formula), enter the expression and set Output type to **VARCHAR**.

### Expression

```
rtrim('  hello  ')
```

### Result

```
'  hello'
```

To use your own data, replace the example values with column names. Keep format strings and other options as written.

Try it live in Formula

Result
| id | result |
| --- | --- |
| 1 | hello |

## Arguments and types

```
rtrim(string, characters)
```

**string**

Text

**characters**

Text

Supported signatures (2)

```
rtrim(string: VARCHAR) → VARCHAR
rtrim(string: VARCHAR, characters: VARCHAR) → VARCHAR
```

The result type can depend on the input types. See DuckDB for the full argument rules.

## Things to know

If the first argument is missing, the result is NULL.

## Related functions

[ltrim

Remove spaces from the start of text. Pass a second argument to remove those characters instead.

](https://oplema.com/docs/strata/functions/ltrim)[trim

Remove spaces from both ends of text. Pass a second argument to remove those characters instead.

](https://oplema.com/docs/strata/functions/trim)[translate

Swap individual characters: each character in the second argument becomes the character at the same position in the third. Characters with no counterpart are removed.

](https://oplema.com/docs/strata/functions/translate)[lpad

Add a character to the left of text until it reaches a given length. Longer text is cut from the right to that length.

](https://oplema.com/docs/strata/functions/lpad)

[Browse text](https://oplema.com/docs/strata/functions#text) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/text.html#rtrimstring-characters)

Function metadata from DuckDB, used under the [MIT license](https://github.com/duckdb/duckdb/blob/v1.5.4/LICENSE).
