Skip to Content
avatar image
Former Member

Last day of month in Scheduler

Greetings!

I have created a transaction that must be executed as a scheduler job with the next pattern:

Frequency: every day, every hour, at 00 minutes;

First start: 00:00 at the 3rd day of a month;

Last start: 00:00 at the last day of a month;

I have successfuly configurated job execution frequency and I know how to set period of days in month for transaction execution (i.e. from 3rd to 31st). But different months has different durations:

  • 28 (29) days for February;
  • 30 days - April, June, September, November;
  • 31 days - January, March, May, July, August, October, December.

Unfortunately I have problems with determination of the last day of a month in scheduler. So is it possible to do this?

As I had no idea how set last job start at the last day of month, I developed the following approach - create three different transaction schedulers for months with the same duration. For example, for those months that have 31 days, scheduler pattern will look like:

00 00 00 3-31 0,2,4,6,7,9,11 *

I have doubts that this approach a good idea..

Can someone give any suggestions?

Any help will be greatly appreciated!

Best Regards,

Vitaliy

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    May 09, 2013 at 08:50 AM

    Hi Vitaliy,

    I think regarding your question, I would have the transaction run every hours with a simple pattern.

    Then in the transaction, you can use an expression to check the last day of the month (Function monthend(Date)) and get the date period in which the transaction should not run.

    If you are in the date period, then you would be able to stop the transaction with the stop action bloc.

    Then you don't have any issues with leap year, 30 days months, 31days months etc..

    May just be what you're trying to avoid but seems a bit simpler than having different scheduled jobs.

    Cheers,

    Arnaud

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 08, 2013 at 04:50 PM

    Vitaliy , I am not sure there is any out of box pattern which meets your criteria .

    But i have a question though for you: Doesn't it mean you included all scenario's when you configured the job with 31 day month?

    And approach you mentioned, if you schedule 3 jobs, looks like your job runs 3 times for every hour on most days of the month.

    And i have some other simple ideas you can achieve this.

    1. Schedule the job of every one hour,every day. Check inside the transaction if date is not between 1 to 3 and decide the execution path.

    2. If you have formulated a pattern successfully if you you know the number of days in a month,

    Then you can write a another Transaction and execute on start of first day of month and update your pattern in XMII_JOBS table for your job. This may not be the best approach considering best practices.

    Hope this helps.

    Thanks

    Hari

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 10, 2013 at 05:42 AM

    Hello Hari and Arnaud!

    Thank you a lot for replies, it was realy helpfull!

    I will add some action blocks into a transaction to check current date according to required criterias. If date is in correct bounds, then transaction will run main execution path, else it will be stopped by "Terminate Transaction" action block.

    Thank again!

    Best Regards,

    Vitaliy

    Add comment
    10|10000 characters needed characters exceeded