When using format(as.Date(c("2020-10-04", "2020-10-05")), "%U") (the first date is sunday, the second date is monday) I get week 40 for both dates. What do I have to do in order to let the week start on Monday?
Asked
Active
Viewed 54 times
0
Ronak Shah
- 355,584
- 18
- 123
- 178
D. Studer
- 1,279
- 12
- 25
2 Answers
2
Use "%V" :
format(as.Date(c("2020-10-04", "2020-10-05")), "%V")
#[1] "40" "41"
Ronak Shah
- 355,584
- 18
- 123
- 178
1
format(as.Date(c("2020-10-04", "2020-10-05")), "%W")
Check out ?strptime for the full documentation on it
Edo
- 6,770
- 2
- 6
- 18