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 :
Small and medium business | Business Central, N...
Suggested answer

Making datetime field empty

(0) ShareShare
ReportReport
Posted on by 391

I want to remove datetime values from a field of a table using code. 

There is already some value in the datetime field. If I want to make that field empty.

Methods I have tried:

1.   RandomTable."Approval Date Time" := 0DT;

      RandomTable.Modify;

2.  CLEAR(RandomTable."Approval Date Time");

If I try code like below then it updates the field with current datetime but I am unable to clear its value using above two methods.

 

RandomTable."Approval Date Time" := CURRENTDATETIME;

RandomTable.Modify;

Any help in this regard is highly appreciable.

I have the same question (0)
  • Bilal Haider Profile Picture
    391 on at
    RE: Making datetime field empty

    Thanks Hussnain for your response.

    I am already fetching the record using find function. There are other fields needed to be updated in the same record and all other fields are updating as required. Only this field is not updating.

  • M Hussnain Javed Profile Picture
    241 on at
    RE: Making datetime field empty

    Hi Bilal Haider,

    Both methods are correct but you're missing 1 thing in both methods.

    Before assigning a value to a field we first get that field in the code.

    So before assiging 0DT to Approval Date Time, you need to get that field by using setfilter or setrange.

    If you've received your answer, pleaser verify it to help others.

  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: Making datetime field empty

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,689 Super User 2025 Season 2

#2
Sumit Singh Profile Picture

Sumit Singh 2,631

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,212

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans