我有两列,Year
和weekoftheyear
(0-52)。我如何知道一年中的特定周,例如2014年的第一周或最后一周有多少天?
答案 0 :(得分:0)
根据周开始日调整如下:
strptime(paste(my_year,my_week,"Saturday"), "%Y %U %A")-strptime(paste(my_year,my_week,"Sunday"), "%Y %U %A")+1
strptime(paste("2014","1","Saturday"), "%Y %U %A")-strptime(paste("2014","1","Sunday"), "%Y %U %A")+1
Time difference of 7 days
与以下相同
strptime(paste("2014","2","Sunday"), "%Y %U %A")-strptime(paste("2014","1","Sunday"), "%Y %U %A")
Time difference of 7 days