I have a column with start dates and end dates (plus times).
Then I'd have 31 separate columns, one for each day of the month that contains a 1 or 0 if the start and end dates encompass the day in the column.
I have converted the date values into dates using strptime
. I know how to use difftime
.
The bit i'm stuck on is actually doing the comparison and checking whether the start date is before or after the date of the column. e.g. i want to know if the start and end date includes the 1st of Jan, then the 2nd of Jan......if the start date is the 5th, i should return 0 for those 2 columns but I don't know how to make the comparison.
Added some sample data
- Col 1 Start Date: 01/01/2015 17:00:00
- Col 2 End Date: 14/01/2015 10:55:00
- Col 3 Jan-01: 1
- Col 3 Jan-02: 1
So in columns 3, i'd want to check if start and end date encompasses the 1st of Jan.
The start date can be at some point on the 1st of Jan, e.g. 4pm. If this is the case, i'd like column 3 to return 0.5 days.
- Col 1 Start Date: 01/01/2015 00:00:00
- Col 2 End Date: 01/01/2015 16:00:00
- Col 3 Jan-01: 0.6667
- Col 3 Jan-02: 0
Hopefully this is now more clear. I think the complexity of having time and not just returning a Boolean result means this is not a duplicate question.