Learn R Programming

whapi (version 0.0.2)

whapi_fmt_date: Safe date formatting

Description

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 = "-")

Value

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

Arguments

x

Date or coercible to Date.

fmt

Date format passed to base::format().

na

Fallback string if the input is missing.

Examples

Run this code
whapi_fmt_date(Sys.Date())
#> "31/08/2025"
whapi_fmt_date(NA)
#> "-"

Run the code above in your browser using DataLab