Skip to content

Formats a date safely, returning a fallback value (na) when the input is NULL or NA.

Usage

whapi_fmt_date(x, fmt = "%d/%m/%Y", na = "-")

Arguments

x

Date or coercible to Date.

fmt

Date format passed to base::format().

na

Fallback string if the input is missing.

Value

A formatted date string, or the na placeholder if missing.

Examples

whapi_fmt_date(Sys.Date())
#> [1] "10/09/2025"
#> "31/08/2025"
whapi_fmt_date(NA)
#> [1] "-"
#> "-"