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

Making datetime field empty

(0) ShareShare
ReportReport
Posted on by 414

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)
  • Suggested answer
    Marco Mels Profile Picture
    on at

    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.

  • M Hussnain Javed Profile Picture
    241 on at

    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.

  • Bilal Haider Profile Picture
    414 on at

    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.

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,151

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,443 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,092 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans