# Extracting Week Number of Dates Vector in R (Example Code)

In this R tutorial you’ll learn how to convert dates to week numbers.

## Creating Example Data

x <- c("2018-01-01", "2025-05-13", "2021-10-08") # Vector of dates x # Print dates to RStudio console # [1] "2018-01-01" "2025-05-13" "2021-10-08" |

x <- c("2018-01-01", "2025-05-13", "2021-10-08") # Vector of dates x # Print dates to RStudio console # [1] "2018-01-01" "2025-05-13" "2021-10-08"

## Example: Extracting Week Number of Date in R

strftime(x, # Returning week number format = "%V") # [1] "01" "20" "40" |

strftime(x, # Returning week number format = "%V") # [1] "01" "20" "40"

## Further Resources

You may find some related R programming language tutorials on topics such as numeric values, data objects, and dates in the following list: