Problem
We would like to calculate the number of elapsed and remaining days in a year.
Solution
date<- as.Date("2019-03-29")
# Elapsed days
date - as.Date(ISOdate(format(Sys.Date(), "%Y"), 1, 1)) + 1
Time difference of 88 days
# Remaining days
as.Date(ISOdate(format(Sys.Date(), "%Y"), 12, 31)) - date
Time difference of 277 days
# Elapsed days
Sys.Date() - as.Date(ISOdate(format(Sys.Date(), "%Y"), 1, 1)) + 1
Time difference of 153 days
# Remaining days
as.Date(ISOdate(format(Sys.Date(), "%Y"), 12, 31)) - Sys.Date()
Time difference of 212 days
Related entries
No hay comentarios:
Publicar un comentario