Skip to main content
Post a question

Notifications

Community site session details

Community site session details

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

Database Log Clean Up Batch Job

Like (1) ShareShare
ReportReport
Posted on 10 Apr 2024 19:32:44 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
    497 on 29 May 2024 at 14:12:06
    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 28 May 2024 at 08:46:25
    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 15 Apr 2024 at 07:26:36
    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 11 Apr 2024 at 04:16:47
    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 11 Apr 2024 at 02:53:30
    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,729 Super User 2025 Season 1 on 10 Apr 2024 at 20:39:49
    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!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March 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,729 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,718 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans
Loading started
Loading complete