Hi everyone, I am trying to calculate the number of days between any two dates in a year regardless of the year. Specifically, image two dates: MonDay1 <- "01-30" #January 30 MonDay2 <- "12-31" #December 31
I want the difference of those two dates to be MonDay1- MonDay2=30 days #January is closer to December from the prior year than to the December in the year when January is. FYI. this calculation is to count the number of days between any given date to the peak of the summer, which in the southern hemisphere can be around December. Unfortunately, I have not been able to make R recognize a date as just Mon-Day. If I try: MonDay1<-as.Date("01-30",format="%m-%d") # this automatically assigns the current year [1] "2015-01-30" This following code allows to define just Mon-Day but it is recognized as character: format(strptime("07-30", format="%j"), format="%m-%d") Any help will be greatly appreciated, Thanks, Camilo ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.