Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / Database Log Clean Up ...
Finance forum
Answered

Database Log Clean Up Batch Job

Posted on by 87
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
    Brian Sanderson Profile Picture
    Brian Sanderson 259 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
    MBates237 87 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
    Hana Xue 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
    Bharani Preetham Pe... 3,526 Super User 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
    Hana Xue 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
    André Arnaud de Cal... 283,907 Super User 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)).

Helpful resources

Quick Links

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,907 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,189 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans