SPSchedule.FromString(recurrenceValue) - syntax/format for recurrence value
This blog posting applies to Microsoft Office SharePoint Server 2007.
The SPSchedule class allows one to specify repeating schedules for timer jobs using derived classes such as SPMinuteSchedule, SPHourlySchedule, etc. Those are pretty easy to figure out from the SDK (https://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spschedule.aspx).
SPSchedule also provides a FromString(recurrenceValue) method that allows you to specify the same kinds of schedules from a text string, but allowable formats for the recurrenceValue string are not well documented. Here are legal formats I’ve discovered through testing.
Formats Used Below
Format |
Description |
Allowable values |
m |
minutes |
0-59 |
s |
seconds |
0-59 |
ddd |
abbreviated name of day of week |
mon, tue, wed, thu, fri, sat, sun |
d |
numeric day of month |
1-31 |
mmm |
abbreviated name of month |
jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec |
HH:MM:SS |
Time of day as hours, minutes, seconds using 24 hour-clock. |
00:00:00 - 23:59:59 |
Minute Schedule
Syntax |
Description |
every Interval minutes |
Repeat every Interval minutes (starting at 0 seconds) |
every Interval minutes at Begin |
Repeat every Interval minutes starting at Begin seconds |
every Interval minutes between Begin and End |
Repeat every Interval minutes starting between Begin and End seconds |
Parameter |
Format |
Sample |
Interval |
m |
every 15 minutes |
Begin |
s |
every 15 minutes at 0 |
End |
s |
every 15 minutes between 0 and 15 |
Hourly schedule
Syntax |
Description |
hourly at Begin |
Repeat every hourstarting at Begin minutes |
hourly between Begin and End |
Repeat every hour starting between Begin and End minutes |
Parameter |
Format |
Sample |
Begin |
m |
hourly at 1 |
End |
m |
hourly between 1 and 10 |
Daily schedule
Syntax |
Description |
daily at Begin |
Repeat every daystarting at Begin time |
daily between Begin and End |
Repeat every day starting between Begin and End times |
Parameter |
Format |
Sample |
Begin |
HH:MM:SS |
daily at 09:00:00 |
End |
HH:MM:SS |
daily between 09:00:00 and 17:30:00 |
Weekly schedule
Syntax |
Description |
weekly at Begin |
Repeat every weekstarting at Begin day and time |
weekly between Begin and End |
Repeat every week starting between Begin and End day and times |
Parameter |
Format |
Sample |
Begin |
ddd HH:MM:SS |
weekly at mon 09:00:00 |
End |
ddd HH:MM:SS |
weekly between mon 09:00:00 and fri 17:30:00 |
Monthly schedule
Syntax |
Description |
monthly at Begin |
Repeat every monthstarting at Begin day of month and time |
monthly between Begin and End |
Repeat every month starting between Begin and End day of month and times |
Parameter |
Format |
Sample |
Begin |
d HH:MM:SS |
monthly at 1 09:00:00 |
End |
d HH:MM:SS |
monthly between 1 09:00:00 and 15 17:30:00 |
Yearly schedule
Syntax |
Description |
yearly at Begin |
Repeat every yearstarting at Begin month, day of month and time |
yearly between Begin and End |
Repeat every year starting between Begin and End month, day of month and times |
Parameter |
Format |
Sample |
Begin |
mmm d HH:MM:SS |
yearly at jan 1 09:00:00 |
End |
mmm d HH:MM:SS |
yearly between feb 1 09:00:00 and apr 15 17:30:00 |
Comments
Anonymous
March 21, 2007
Nice post! There are few like this around, I guess you could help me with some questions: Do you know what happens if you don't set the End time? Would that means that the job will start on the exact time of the begin value? And if for example the repeating time is set to every 5 minutes, and the task takes 10 minutes to complete, what happens there? ThanksAnonymous
July 02, 2007
How about adding this to the Community Content section of the MSDN page? http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spschedule.fromstring.aspxAnonymous
August 16, 2007
I need to create a schedule for a service that needs to run every few seconds. Is this possible? Should I just create a new class that inherits from SPSchedule?Anonymous
February 19, 2009
SharePoint SPSchedule.FromString(recurrenceValue) - syntax/format for recurrence value Using Javascript