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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Database Log Clean Up Batch Job

(1) ShareShare
ReportReport
Posted on by 211
Hello everyone. 
 
My organisation's database log has become incredibly large and I'm trying to tackle it. With help from Microsoft we've deleted a lot of the data directly using SQL. However, I now want to keep on top of the maintenance. I've tried to run the database log clean up job with (DateRange(-30,-0)) to delete anything older than 30 days but it doesn't appear to work, I've only had success when explicitly specifying a date, which I don't want to do if I'm scheduling a recurring batch job.
 
Any tips on setting up a recurring clean up job please?
 
Thanks,
Michael 
I have the same question (0)
  • Verified answer
    André Arnaud de Calavon Profile Picture
    300,731 Super User 2025 Season 2 on at
    Hi Michael,
     
    Can you explain the behavior when you mention "it doesn't appear to work"? Note that the date range is now set to the last 30 days, not older than 30 days. For older than 30 days, you can use the query syntax (LessThanDate(-30)).
  • Verified answer
    Hana Xue Profile Picture
    Microsoft Employee on at
    Hi,
    Please check your date range settings, you want to delete data that is more than 30 days in the past, please use the lessthan method.

    Best Regards,
    Hana
     
  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    Seems you are using wrong syntax to fetch dates older than 30 days. You should use this
     
    • Less than thirty days from now â€“ Enter (LessThanDate(30)).
  • Hana Xue Profile Picture
    Microsoft Employee on at
    Hi,
    If the answer is helpful ,please mark it as verified to help more people in the forum.
    Best Regards,
    Hana
  • MBates237 Profile Picture
    211 on at
    Just an update on this one, I've run the cleanup job to delete everything older than a year
     
     
    But it seems to have just deleted everything as there are now only records from today in the DB log (this is the view sorted by oldest to newest) Should it have been (LessThanDate(-365)) i.e. anything older than 1 year ago?
     
     
     
  • Verified answer
    Bryan Sanderson Profile Picture
    778 on at
    Yes, it should have been (LessThanDate(-365)). The query you ran was in essence saying anything older than 365 days from today, aka go a year from today and delete everything older than that.
     

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 683 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 563 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans