web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Date period for batch job needs to be dynamic using runbasebatch x++

(0) ShareShare
ReportReport
Posted on by 55

Hi,

The report will be planned to run in batch. The date period for batch needs to be dynamic. It’s planned to be run monthly to be run on the 3rd of each month. For batch, the date interval be used, so a date interval for the 3rd of or the previous month to the 3rd of the current month can be setup. If date intervals are used, then the ability to override the from and to dates should be allowed. kindly pls advice how can i do.

Thanks Advance


LakshmikanthanK

*This post is locked for comments

I have the same question (0)
  • Lakshmikanthan K Profile Picture
    55 on at
    RE: Date period for batch job needs to be dynamic using runbasebatch x++

    Hi Sukrut,

    i want to set recurrence in code .if i set FromDate -3rd of the month (like oct 3rd ) the ToDate -should be next month 3rd (like 3rd nov) should be get automatically.So i need to do in my batch job.Any suggestions pls let me know

    Thanks

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Date period for batch job needs to be dynamic using runbasebatch x++

    Hi Lakshmikanthan,

    there is no need to run the recurrence from code.

    1) set the recurrence to  run the job on 3rd of every month from dialog

    2) in run method get system date. example : Since job runs on 3rd of every month if job runs on 3rd of November system date would be 11/03/2017

    3) 11/03/2017 would be To date in your case. ( todate = sysdate)

    4) you need to get from date by subtracting 1 from the month 11 -1 that would 10/03/2017, x++ functions are available to do so.  Use this from date and to date as ranges wherever required.

    5) steps 2-4 repeats every time when batch job runs.

    6) You need to add few additional conditions if year changes. Example: for 01/03/2018 since month is 1 you can not subtract from it by default set the month to 12 and subtract 1 from year that will be 12/03/2017.

    Hope this will help you.

    Regards

    raghu

  • Martin Dráb Profile Picture
    236,320 Most Valuable Professional on at
    RE: Date period for batch job needs to be dynamic using runbasebatch x++

    Note that there is a duplicate thread on DUG forum, where the reply "You can use nextMth() function to get the date in the next month" has been marked as the verified answer.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans