{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":40035,"path":"platform-administration/time-configuration/r_SpecialCasesInJobSchedules.md","title":"Special cases in job schedules","bundle":null,"doc_type":null,"release":"australia","body":"\n# Special cases in job schedules\n\nSome special cases require care in job scheduling.\n\n## End of the month schedules\n\nBecause months have different lengths, take care when scheduling jobs for the end of the month.\n\n-   Scheduling an event for the 29th or 30th is not recommended, because the scheduled job is executed in months \\(like February\\) which are shorter than those dates.\n-   If an event is scheduled for the 31st, it executes on the last day of the month, even if the month is shorter.\n\nFor example, something scheduled to run on the 31st of the month runs on February 28 or February 29 in a leap year.\n\n## Weekday schedules\n\nFor scheduled scripts, use the following script to run only on weekdays:\n\n**Warning:** Conditional scripts for scheduled report emails are executed in the sandbox. Therefore, function definitions are not allowed. Some API calls and keywords are also not allowed.\n\n```\n\nvar isWeekday;\nvar today = new Date();\nvar dayOfWeek = today.getDay(); // Get day of the week(0 = Sunday, 1 = Monday, ... , 6 = Saturday)\nswitch (dayOfWeek) {\ncase 0: // Sunday\ncase 6: // Saturday\nisWeekday = false;\nbreak;\ndefault:\nisWeekday = true;\n}\nanswer=isWeekday;\n```\n\nIf the conditional script on a Scheduled Report is more complex and you need to make use of our Glide classes, then please use the following steps as a workaround:\n\n1.  Create a Scheduled Job and complete all the conditional logic of the Scheduled Report inside the Scheduled Job.\n2.  If all the conditional logic is satisfied, you can trigger the Scheduled Report with the following script inside the Scheduled Job.\n\n    ```\n    var schRpGr = new GlideRecord(\"sysauto_report\");\n    schRpGr.get(\"<sys_id of the scheduled report>\");\n    gs.executeNow(schRpGr);\n    ```\n\n\n## Scheduled jobs from scripts\n\nTo execute a scheduled job triggered by an event, use the following script:\n\n```\n//Execute a scheduled script job\nvar rec = new GlideRecord('sysauto_script');\nrec.get('name', 'YOUR_JOB_NAME_HERE');\nSncTriggerSynchronizer.executeNow(rec);\n```\n\nYou can run the script using one of several tables:\n\n-   scheduled\\_import\\_set \\(Scheduled Import Sets\\)\n-   sysauto\\_script \\(Scheduled Script Execution\\)\n-   sysauto\\_template \\(Scheduled Template Generation\\)\n-   sysauto\\_report \\(Scheduled Report\\)\n\n**Note:** `SncTriggerSynchronizer` does not provide methods to execute scheduled jobs in the future.\n\n## Running scheduled scripts and jobs imported from another instance\n\nScheduled Script Execution and Scheduled Jobs are categorized as data records in the ServiceNow AI Platform, which means they are excluded from update sets. To determine if a table is included, navigate to **All** &gt; **System Definition** &gt; **Dictionary** and view the **Attribute** value for the table in question. Only tables with the attribute update\\_sync=true are included in update sets.\n\nYou can optionally export and import data records via XML. However, to prevent unexpected data changes, Schedule Item \\[sys\\_trigger\\] records are not created for data records imported from an XML file such as an update set. To run scheduled jobs or scripts imported from another instance, update the corresponding job or script record in the target instance.\n\n**Parent Topic:**[Scheduled jobs](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/time-configuration/c_ScheduledJobs.md)\n\n**Related topics**  \n\n\n[Advanced options for scheduled jobs](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/time-configuration/advanced-options-for-scheduled-jobs.md)\n\n[Create a scheduled job](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/time-configuration/t_CreateAScheduledJob.md)\n\n[Enable run types for scheduled job child tables](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/time-configuration/customize-run-times-for-scheduled-jobs.md)\n\n[Personalize the system date format](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/time-configuration/t_PersonalizeTheSystemDateFormat.md)\n\n[Set a system time zone](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/time-configuration/t_SetASystemTimeZone.md)\n\n[Domain separation for service providers](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-security/domain-sep-landing-page.md)\n\n"}}