# SQL Extension 2.0: Cron Schedule Spanning Midnight

**URL:** <https://community.dynatrace.com/t/sql-extension-2-0-cron-schedule-spanning-midnight/56800>\
**Category:** Extensions\
**Tags:** databases, extensions, cron\
**Created:** [August 25, 2026, 5:37am UTC](https://community.dynatrace.com/t/sql-extension-2-0-cron-schedule-spanning-midnight/56800 "2026-08-25T05:37:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![p\_devulapalli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/p_devulapalli/32/41590_2.png) [@p\_devulapalli](https://community.dynatrace.com/u/p_devulapalli)\
**Post date:** [August 25, 2026, 5:37am UTC](https://community.dynatrace.com/t/sql-extension-2-0-cron-schedule-spanning-midnight/56800/1 "2026-08-25T05:37:50Z")

</div>

I’m configuring a SQL Extension&nbsp; and need to schedule data collection every hour from 5:00 PM to 8:00 AM daily.

I’ve tried using a Cron expression as of below but the extension keeps throwing an error “Schedule is not a valid quartz Cron expression”

0 17-23,0-8 \* \* ?

 ![p_devulapalli_0-1787635482182.png](https://global.discourse-cdn.com/dynatrace/original/3X/3/7/372f23f5f25dc63123bd0ff70aad942500717b9a.png)

This does shows as valid when I verify using&nbsp;[https://www.javainuse.com/cron](https://www.javainuse.com/cron)

Just wondering if the extension supports&nbsp;combining ranges and lists in the same field (17-23,0-8) or do I need to create two different schedules to achieve this?

0 17-23 ? \* \*0 0-8 ? \* \*Any advice please?

---

<div class="post-metadata">

**Author:** ![p\_devulapalli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/p_devulapalli/32/41590_2.png) [@p\_devulapalli](https://community.dynatrace.com/u/p_devulapalli)\
**Post date:** [September 1, 2026, 2:05am UTC](https://community.dynatrace.com/t/sql-extension-2-0-cron-schedule-spanning-midnight/56800/2 "2026-09-01T02:05:37Z")

</div>

If anyone interested , managed to find a workaround to this issue , here is what worked for me

The [schedule](https://docs.dynatrace.com/docs/shortlink/sql-reference#schedule) parameter needs to align with the regex pattern defined in the schema and the regex pattern does not seem to support&nbsp;&nbsp;multiple ranges&nbsp;like “0 17-23,0-8 \* \* ?” which span overnight

 ![p_devulapalli_0-1788227066654.png](https://global.discourse-cdn.com/dynatrace/original/1X/db4a0abe74d01ebb28adee8f08266d223cbb737e.png)

workaround is to use it as a [variable](https://docs.dynatrace.com/docs/shortlink/sql-reference#control-frequency) , and define the cron schedule as a variable . This removes the limitations that is caused by the regex in schema

1)&nbsp;Declare the variable in _vars_

```markup
vars:
  - id: "businessHoursSchedule"
    displayName: "Business Hours Schedule"
    description: "Cron Schedule for Business Hours"
    type: "text"
    defaultValue: "0/10 8-16 ? * *"
  - id: "AfterHoursSchedule"
    displayName: "After Hours Schedule"
    description: "Cron Schedule for After Hours"
    defaultValue: "0 17-23,0-8 ? * *"
    type: "text"​

```

2)&nbsp;Reference the variable in the&nbsp;_schedule_&nbsp;field

```markup
sqlOracle:
  - group: "ABC"
    subgroups:
      - subgroup: "AfterHours"
        schedule: "var:AfterHoursSchedule"

....................
      - subgroup: "BusinessHours"
        schedule: "var:BusinessHoursSchedule"

```

When the extension is activated, users can provide their own cron expression in the schedule field via the extension configuration UI or it defaults to using what’s defined in the extension yaml

 ![p_devulapalli_1-1788228232317.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/a/2a1d478f35f60d825fd81cbd5c97073d89ba1829.png)  
Hope this helps
