I am not finding this anywhere in Help at Salesforce or via Google.

WHen I schedule Apex via the Developer's Console (a weekly run), is it NOT possible to have the first run in LESS than a WEEK?

Cls_BatchCreateOpportHistryWeeklySchd OppOwner_Weekly = new Cls_BatchCreateOpportHistryWeeklySchd ();
String schWeek = '0 30 2 ? * SUN'; // Every Sunday 
String jobIDW = system.schedule('WEEKLY Opp Owner History', schWeek, OppOwner_Weekly);

This was instantiated on 3/2/2015 at 8am. The first scheduled run, no matter how I delete and retry, is for 3/15 (instead of 3/8, just under six days from 3/2).

So, I actually need to set a reminder to me to manually run this one time, or..?


  • So your issue is that you are trying to get your job to run for 0 30 2 ? * SUN, which should be every Sunday at 2:30am, but when you run it on Monday March 2nd it is skipping Sunday March 8th and starting on Sunday March 15th instead? – BarCotter Mar 2 '15 at 13:58
  • Yes that (was) the case. Not the end of the world (though I DID forget to set a reminder for myself, so...). Anyway. – AMM Mar 12 '15 at 12:50
  • 1
    It sounds like a bug with SalesForce. You may want to raise a case with them. I tend to allow my schedulable class to have a date passed into it, ie the execution date. The code will use the execution date rather than Date.today() when running the job. This means if you ever forget to run a job you can execute it with the correct date passed in. – BarCotter Mar 12 '15 at 13:32

Not sure about this ; but no need to set reminder. One alternate is to schedule it for next sunday by setting 'day of the month' Your string could be : String schday = '0 30 2 8 3 ? SUN';

| improve this answer | |
  • Joyously... I did not even set the reminder for myself, so I ran it the first time a day late. Good job, numb nut, I literally said out loud. Thanks in any case. – AMM Mar 12 '15 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.