Skip to contents

Finds the closest matching datetime before (before=TRUE), after (before=FALSE) or either (default or if before=NA)

Usage

find_closest_datetime(dates, x, before = NA)

Arguments

dates

a vector of dates or datetimes

x

a single date or datetime

before

Leave as NA (the default) to find the closest or specify a boolean if the closest datetime should be before x (if TRUE) or after x (if FALSE)

Value

A logical vector of length dates.