web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Removing DateTime value from a field of a table record using code

(0) ShareShare
ReportReport
Posted on by 442

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
    Suresh Kulla Profile Picture
    50,269 Super User 2026 Season 1 on at

    After you run the first code what value are you seeing in that field? usually on SQL side there is a default value for those fields something like 1753....

  • Bilal Haider Profile Picture
    442 on at

    After running first code I see the same old value that is populated before by using the CURRENTDATETIME function.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,269 Super User 2026 Season 1 on at

    That is not possible unless there is another code which is overwriting it again. What version you are using?

  • Bilal Haider Profile Picture
    442 on at

    It is BC 1416 OnPrem

  • Verified answer
    Suresh Kulla Profile Picture
    50,269 Super User 2026 Season 1 on at

    DateTime.gif

    Tested this on BC14 and I don't see any issue. I just used the below code under update action

    "Created On" := 0DT;
    MODIFY;

  • Bilal Haider Profile Picture
    442 on at

    Hi,

    Thanks Suresh for going beyond for helping me. I acknowledge it.

    But I am using C/AL code in background to update these fields without getting user input. But I will check my code again.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,269 Super User 2026 Season 1 on at

    The above example is also in CAL on BC 14

  • Suggested answer
    Bilal Haider Profile Picture
    442 on at

    Yes, this way it has worked. I was trying to change multiple records that are coming to filter like this:

    TableVariable.MODIFYALL(DateTime,0DT);

    Now I have loop over all filtered records and used:

    TableVariable.DateTime := 0DT;

    TableVariable.Modify;

    But I am still confused why it was not working for all filtered using ModifyAll because all other fields are updating correctly using ModifyAll.

    Anyways, it worked for now and thanks for your answer. I have verified that.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,857 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,047 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Liquid error: parsing "/blogs/post/?postid=%27nvOpzp;%20AND%201=1%20OR%20(%3C%27%22%3EiKO))," - Too many )'s.