Skip to main content

Notifications

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 184
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 
  • Verified answer
    Bryan Sanderson Profile Picture
    478 on at
    Database Log Clean Up Batch Job
    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.
     
  • MBates237 Profile Picture
    184 on at
    Database Log Clean Up Batch Job
    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?
     
     
     
  • Hana Xue Profile Picture
    Microsoft Employee on at
    Database Log Clean Up Batch Job
    Hi,
    If the answer is helpful ,please mark it as verified to help more people in the forum.
    Best Regards,
    Hana
  • Bharani Preetham Peraka Profile Picture
    3,624 Moderator on at
    Database Log Clean Up Batch Job
    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)).
  • Verified answer
    Hana Xue Profile Picture
    Microsoft Employee on at
    Database Log Clean Up Batch Job
    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
     
  • Verified answer
    André Arnaud de Calavon Profile Picture
    293,302 Super User 2025 Season 1 on at
    Database Log Clean Up Batch Job
    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)).

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,302 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,114 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans