function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
College ManagementCollege Management 

Cron Expression to schedule Weekdays from given datetime.

Hi, Please see the below cron expression, As it is not possible to pass value for both day of month and day of week i got stuck. My requirement is to run cron for weekdays starting from given day of month to endDate.

CRON = '' + startDate.second() + ' ' + startDate.minute() + ' ' + startDate.hour() + ' ' + startDate.day()+'/'+7 + ' ' + startDate.month() +'-'+endDate.month() + ' ? ' + ' ' + startDate.year()+'-'+endDate.year();

In the above underlined part (ie., Day of month ) i want to run cron on weekdays (i.e., From MON-WED) starting from given day of month.
The below cron works fine but it is starting from next available weekday. But i want to run the job for every weekdays starting from given day of month.
CRON = '' + startDate.second() + ' ' + startDate.minute() + ' ' + startDate.hour() + ' ' + '?' + ' ' + startDate.month() +'-'+endDate.month() + ' MON-FRI ' + ' ' + startDate.year()+'-'+endDate.year();

How can i achieve the below cron ??

CRON = '' + startDate.second() + ' ' + startDate.minute() + ' ' + startDate.hour() + ' ' + startDate.day() + ' ' + startDate.month() +'-'+endDate.month() + ' MON-FRI ' + ' ' + startDate.year()+'-'+endDate.year();

Please please help me out .. Its very urgent. Please.

Thanks !
ShashankShashank (Salesforce Developers) 
Please see if this helps: http://salesforce.stackexchange.com/questions/12482/how-to-set-the-start-and-end-date-in-the-cron-expression
http://www.chiragmehta.info/chirag/2009/11/12/salesforce-schedule-apex-to-run-at-any-time-interval/