Skip to contents

Returns the field_start and field_end dataset-level metadata keys from a survey design object or a data frame.

Usage

extract_field_dates(x)

Arguments

x

A survey design object or data.frame.

Value

A named list of length 2, field_start then field_end, each a Date of length 1. An unset key is as.Date(NA).

Details

Returns the two structured dates only. The prose field period has its own extractor, extract_field_period(), and this function never derives one from the other. An unset key is a normal state, reported as as.Date(NA); this function never warns. A design object restored from a file written by surveycore 1.1.0 or earlier reports both entries as as.Date(NA) rather than failing.

Examples

df <- data.frame(id = 1:5, y = c(2, 4, 3, 5, 1), w = rep(1, 5))
extract_field_dates(df)
#> $field_start
#> [1] NA
#> 
#> $field_end
#> [1] NA
#> 

df <- set_field_dates(df, "2026-02-10", "2026-03-04")
extract_field_dates(df)
#> $field_start
#> [1] "2026-02-10"
#> 
#> $field_end
#> [1] "2026-03-04"
#>