Skip to contents

Date conversion from Eurostat time format. A function to convert Eurostat time values to objects of class base::Date() representing calendar dates.

Usage

eurotime2date(x, last = FALSE)

Arguments

x

a charter string with time information in Eurostat time format.

last

a logical. If FALSE (default) the date is the first date of the period (month, quarter or year). If TRUE the date is the last date of the period.

Value

an object of class base::Date().

Details

Available patterns are YYYY (year), YYYY-SN (semester), YYYY-QN (quarter), YYYY-MM (month), YYYY-WNN (week) and YYYY-MM-DD (day).

References

See citation("eurostat"):

# Kindly cite this package by citing the following R Journal article:
#
#   Lahti L., Huovari J., Kainu M., and Biecek P. (2017). Retrieval and
#   analysis of Eurostat open data with the eurostat package. The R
#   Journal 9(1), pp. 385-392. doi: 10.32614/RJ-2017-019
#
# In addition, please provide a citation to the specific software version
# used:
#
#   Lahti L, Huovari J, Kainu M, Biecek P, Hernangomez D, Antal D,
#   Kantanen P (2026). "eurostat: Tools for Eurostat Open Data."
#   doi:10.32614/CRAN.package.eurostat
#   <https://doi.org/10.32614/CRAN.package.eurostat>. R package version
#   4.1.1, <https://github.com/rOpenGov/eurostat>.
#
# To see these entries in BibTeX format, use 'print(<citation>,
# bibtex=TRUE)', 'toBibtex(.)', or set
# 'options(citation.bibtex.max=999)'.

Author

Janne Huovari janne.huovari@ptt.fi

Examples

# \donttest{
na_q <- get_eurostat("namq_10_pc", time_format = "raw")
#> Table namq_10_pc cached at /tmp/RtmpP44Z08/eurostat/c24bf4d30e0b8d4ae4b266455393ee05.rds
na_q$TIME_PERIOD <- eurotime2date(x = na_q$TIME_PERIOD)
unique(na_q$TIME_PERIOD)
#>   [1] "1995-01-01" "1995-04-01" "1995-07-01" "1995-10-01" "1996-01-01"
#>   [6] "1996-04-01" "1996-07-01" "1996-10-01" "1997-01-01" "1997-04-01"
#>  [11] "1997-07-01" "1997-10-01" "1998-01-01" "1998-04-01" "1998-07-01"
#>  [16] "1998-10-01" "1999-01-01" "1999-04-01" "1999-07-01" "1999-10-01"
#>  [21] "2000-01-01" "2000-04-01" "2000-07-01" "2000-10-01" "2001-01-01"
#>  [26] "2001-04-01" "2001-07-01" "2001-10-01" "2002-01-01" "2002-04-01"
#>  [31] "2002-07-01" "2002-10-01" "2003-01-01" "2003-04-01" "2003-07-01"
#>  [36] "2003-10-01" "2004-01-01" "2004-04-01" "2004-07-01" "2004-10-01"
#>  [41] "2005-01-01" "2005-04-01" "2005-07-01" "2005-10-01" "2006-01-01"
#>  [46] "2006-04-01" "2006-07-01" "2006-10-01" "2007-01-01" "2007-04-01"
#>  [51] "2007-07-01" "2007-10-01" "2008-01-01" "2008-04-01" "2008-07-01"
#>  [56] "2008-10-01" "2009-01-01" "2009-04-01" "2009-07-01" "2009-10-01"
#>  [61] "2010-01-01" "2010-04-01" "2010-07-01" "2010-10-01" "2011-01-01"
#>  [66] "2011-04-01" "2011-07-01" "2011-10-01" "2012-01-01" "2012-04-01"
#>  [71] "2012-07-01" "2012-10-01" "2013-01-01" "2013-04-01" "2013-07-01"
#>  [76] "2013-10-01" "2014-01-01" "2014-04-01" "2014-07-01" "2014-10-01"
#>  [81] "2015-01-01" "2015-04-01" "2015-07-01" "2015-10-01" "2016-01-01"
#>  [86] "2016-04-01" "2016-07-01" "2016-10-01" "2017-01-01" "2017-04-01"
#>  [91] "2017-07-01" "2017-10-01" "2018-01-01" "2018-04-01" "2018-07-01"
#>  [96] "2018-10-01" "2019-01-01" "2019-04-01" "2019-07-01" "2019-10-01"
#> [101] "2020-01-01" "2020-04-01" "2020-07-01" "2020-10-01" "2021-01-01"
#> [106] "2021-04-01" "2021-07-01" "2021-10-01" "2022-01-01" "2022-04-01"
#> [111] "2022-07-01" "2022-10-01" "2023-01-01" "2023-04-01" "2023-07-01"
#> [116] "2023-10-01" "2024-01-01" "2024-04-01" "2024-07-01" "2024-10-01"
#> [121] "2025-01-01" "2025-04-01" "2025-07-01" "2025-10-01" "2026-01-01"
#> [126] "2026-04-01" "1991-01-01" "1991-04-01" "1991-07-01" "1991-10-01"
#> [131] "1992-01-01" "1992-04-01" "1992-07-01" "1992-10-01" "1993-01-01"
#> [136] "1993-04-01" "1993-07-01" "1993-10-01" "1994-01-01" "1994-04-01"
#> [141] "1994-07-01" "1994-10-01" "1990-01-01" "1990-04-01" "1990-07-01"
#> [146] "1990-10-01" "1980-01-01" "1980-04-01" "1980-07-01" "1980-10-01"
#> [151] "1981-01-01" "1981-04-01" "1981-07-01" "1981-10-01" "1982-01-01"
#> [156] "1982-04-01" "1982-07-01" "1982-10-01" "1983-01-01" "1983-04-01"
#> [161] "1983-07-01" "1983-10-01" "1984-01-01" "1984-04-01" "1984-07-01"
#> [166] "1984-10-01" "1985-01-01" "1985-04-01" "1985-07-01" "1985-10-01"
#> [171] "1986-01-01" "1986-04-01" "1986-07-01" "1986-10-01" "1987-01-01"
#> [176] "1987-04-01" "1987-07-01" "1987-10-01" "1988-01-01" "1988-04-01"
#> [181] "1988-07-01" "1988-10-01" "1989-01-01" "1989-04-01" "1989-07-01"
#> [186] "1989-10-01"
# }

if (FALSE) { # \dontrun{
# Test for weekly data
get_eurostat(
  id = "lfsi_abs_w",
  select_time = c("W"),
  time_format = "date"
  )
} # }