This sounds like a problem that statisticians occasionally have to deal with. It is quite simple, just convert the string to date or time if you remember what command to use. If your date variable has a value like this 2007-05-31 for May 31, 2007. You can simply use the example below.
For more example on date, I refer you to UCLA R-help page:
For a complete list of date-time formatting conversion see this