Convert the range of date to number of weeks
Usage
getWeekSeq(start_date, end_date, dates, in.format = "%m/%d/%y")
is.Date(x)
not.Date(x)
is.leap(yyyy)
Arguments
- start_date
A scaler of class Date (if this argument is populated, the date arg must be empty)
- end_date
A scaler of class Date; must be later than the start_date (if this argument is populated, the date arg must be empty)
- dates
vector of dates that need not be sequential but that reference values of class Date; Note that if this argument is populated, the start_date and end_date arguments must be empty
- in.format
date input format
- x
date item to check
- yyyy
year numeric value eg 1989
Examples
# simple example with start and end date
getWeekSeq(start_date="12/29/25",end_date="1/8/26")
#> DATE WEEK
#> 1 2025-12-29 52
#> 2 2025-12-30 52
#> 3 2025-12-31 53
#> 4 2026-01-01 1
#> 5 2026-01-02 1
#> 6 2026-01-03 1
#> 7 2026-01-04 1
#> 8 2026-01-05 1
#> 9 2026-01-06 1
#> 10 2026-01-07 1
#> 11 2026-01-08 2
# enter specific dates instead
# specify format
getWeekSeq(
dates = c(
'2025-12-29',
'2025-12-30',
'2025-12-31',
'2026-01-01',
'2026-01-04',
'2026-01-05',
'2026-01-06',
'2026-01-07',
'2026-01-08'),
in.format = "%Y-%m-%d"
)
#> DATE WEEK
#> 1 2025-12-29 52
#> 2 2025-12-30 52
#> 3 2025-12-31 53
#> 4 2026-01-01 1
#> 5 2026-01-04 1
#> 6 2026-01-05 1
#> 7 2026-01-06 1
#> 8 2026-01-07 1
#> 9 2026-01-08 2
getWeekSeq(
dates = c(
'12/29/25',
'12/30/25',
'12/31/25',
'01/01/26',
'01/02/26',
'01/03/26',
'01/06/26',
'01/07/26',
'01/08/26'
),
in.format = "%m/%d/%y"
)
#> DATE WEEK
#> 1 2025-12-29 52
#> 2 2025-12-30 52
#> 3 2025-12-31 53
#> 4 2026-01-01 1
#> 5 2026-01-02 1
#> 6 2026-01-03 1
#> 7 2026-01-06 1
#> 8 2026-01-07 1
#> 9 2026-01-08 2