## Documentation Index

Fetch the complete documentation index at: [/llms.txt](https://helpdocs.gavel.io/llms.txt)

Use this file to discover all available pages before exploring further.

```
The {{ ordinal_number(DateVariable.day, use_word=False) }} day of {{ format_date(DateVariable, format='MMMM yyyy') }}
```

Output: _The 15th day of January 2025_

### Converting text to a date

If you are importing data from another system (such as Clio) where the date field arrives as plain text rather than a date type, use `as_datetime()` with `strftime` to convert it:

```
{{ as_datetime(variable).strftime("%B %d, %Y") }}
```

Use `%-d` instead of `%d` to suppress the leading zero (e.g., “January 3” instead of “January 03”).

### Formatting dates using Calculations (Invisible Logic)

You can also format a date variable through [Calculations](https://helpdocs.gavel.io/workflows/calculations#date-calculations). Create a new Text variable, select your date variable as the source, choose **Format Date** as the operation, and enter the format code. The resulting text variable can then be referenced anywhere in your document with `{{ FormattedDateVariable }}`.

* * *

## Calculating dates

These functions derive new date values from existing ones — useful for deadlines, notice periods, and age calculations.

Age or years elapsed from a date to today

```
    {{ (date_difference(starting=DateVariable).years|int) }}
```

Years between two specific dates

```
    {{ (date_difference(starting=StartDate, ending=EndDate).years|int) }}
```

Months between two dates

```
    {{ (relative_date_difference(starting=StartDate, ending=EndDate).months) }}
```

Add or subtract calendar days, months, or years

```
    {{ format_date( (DateVariable) + date_interval(years=2) ) }}
```

Replace `years` with `months`, `days`, or `weeks`. Use `-` instead of `+` to go back in time.

Add or subtract business days

```
    {{ format_date( (DateVariable) + date_interval(bus_days=10) ) }}
```

Next or prior business day

```
    {{ next_business_day(DateVariable) }}
    {{ prior_business_day(DateVariable) }}
```

Last day of a month

```
    {{ last_day_of_month(DateVariable) }}
```

To extract just the day number (e.g., 30):

```
    {{ format_date(last_day_of_month(DateVariable), format='dd') }}
```

* * *

## Formatting numbers

Use a **Number** question type for decimal values and an **Integer** question type for whole numbers. Apply the functions below in your document template.

If you use a Number question type, decimal points display by default. If you use an Integer question type, you get a whole number.

### Standard number formats

Currency — $100,000.00

```
    {{ currency(variablename) }}
```

No commas, no decimals — 100000

```
    {{ Decimals0NoCommas(variablename) }}
```

Two decimals with commas — 100,000.00

```
    {{ Decimals2Commas(variablename) }}
```

No decimals with commas — 100,000

```
    {{ Decimals0Commas(variablename) }}
```

Custom decimals with commas

```
    {{ format_decimal(variablename, 2) }}
```

Replace the `2` with the number of decimal places you want.

Custom decimals without commas

```
    {{ format_decimal(variablename, 2, False) }}
```

Replace the `2` with the number of decimal places you want.

### Ordinal numbers

Write a number as an ordinal (1st, 2nd, 10th, etc.):

```
{{ ordinal_number(variablename) }}
```

By default, first through ninth are written out as words (first, second, … ninth). To use numerals throughout:

```
{{ ordinal_number(variablename, use_word=False) }}
```

### Numbers written as words

Convert a number to its written-out English form (recommended with the Integer question type):

```
{{ numbers_to_words(variablename) }}
```

Output: _One Hundred Thousand_

### International number formatting

```
{{ format_number_eu(variablename) }}
```

Output: _1.000.000,00_ (European convention — periods as thousand separators, comma as decimal)For Canadian French formatting:

```
{{ "{:,.2f} $".format(variablename).replace(",", " ").replace(".", ",") }}
```

Output: _1 000 000,00_

### Rounding in document templates

Round down (floor) to two decimal places:

```
{{ (variable)|round(2, 'floor') }}
```

Round up (ceiling) to two decimal places:

```
{{ (variable)|round(2, 'ceil') }}
```

When combining rounding with other number formatting, place the rounding call _inside_ the parentheses:

```
{{ "{:,.0f}".format(variablename|round(0,'ceil')) }}
```

* * *

## Formatting special numbers

Use `number_custom()` to force specific punctuation patterns on any number. Have the client enter the value as a **Number** question type, then apply the mask in your template using `n` for each digit position.

- Phone numbers

- Social Security Numbers

- EINs

```
    {{ number_custom(variablename, "(nnn) nnn-nnnn") }}
```

Output: _(555) 555-5555_

```
    {{ number_custom(variablename, "nnn-nnn-nnnn") }}
```

Output: _555-555-5555_

SSN with dashes:

```
    {{ number_custom(variablename, "nnn-nn-nnnn") }}
```

Output: _123-45-6789_SSN with first five digits masked:

```
    {{ number_custom(variablename, "XXX-XX-nnnn") }}
```

Output: _XXX-XX-6789_

```
    {{ number_custom(variablename, "nn-nnnnnn") }}
```

Output: _12-3456789_

* * *

## Formatting words

These functions control capitalization and text transforms. If you want the output to match exactly what the client typed, you do not need any of the functions below.

### Case transforms

APPLE — all caps

```
    {{ variablename|upper }}
```

or

```
    {{ variablename.upper() }}
```

Apple And Pear — title case

```
    {{ title_case(variablename) }}
```

Apple and pear — capitalize first only

```
    {{ capitalize(variablename) }}
```

apple — all lowercase

```
    {{ variablename|lower }}
```

or

```
    {{ variablename.lower() }}
```

### Articles and plurals

Add “a” or “an” before a variable automatically:

```
{{ indefinite_article(variablename) }}
```

Output: _An apple_ / _A pear_

Pluralize a noun based on a count variable:

```
{{ quantity_noun(variablename, "apple") }}
```

Where `variablename` is an Integer. Output: _1 apple_ / _3 apples_

### Punctuation

Add a trailing period only when the text does not already end with one (useful for company names):

```
{{ fix_punctuation(variablename) }}
```

### Verb conjugation

To conjugate a verb based on whether one person, multiple people, or a third-party singular is acting:

1. Create a multiple-choice question with variable name `conjugation` and choices: `1sg`, `3sg`, `pl`.
2. Use this syntax in your template (replacing `allege` with your verb):

```
{{ verb_present('allege', conjugation) }}
```

Output: _allege_ (1sg), _alleges_ (3sg), or _allege_ (pl).Alternatively, use basic conditional logic:

```
allege{% if singular %}s{% endif %}
```

* * *

## Formatting text area questions

Text area variables require special handling to preserve line breaks in the output.

Preserve line breaks

```
    {{ variablename|manual_line_breaks }}
```

Output as a numbered list

```
    {%p for line in VariableName.split("\n") %}{{ loop.index }}. {{ line }}{%p endfor %}
```

Output as a bulleted list

```
    {%p for line in VariableName.split("\n") %}- {{ line }}{%p endfor %}
```

Join lines with commas

```
    {{ commalist(VariableName.split("\n"), "<__str__()>", "") }}
```

Useful when a client enters a multi-line address and you need to output it inline, such as: _Jane Doe, 123 Main Street, Minneapolis, MN 55436_.
