Sometimes, you may need to clear or reset a DateTime field in Business Central. There are two correct ways to do it in AL code.
Table of Contents
Method 1: Assign a Zero DateTime
Following syntax AL program allowed you to assign zero date time
DateTimeField := 0DT;
This sets the field back to a blank or uninitialized state.
Method 2: Use the CLEAR Function
Second method to clear the Date Time field value for Business Central AL Program is as follows
CLEAR(DateTimeField);
This also removes the stored value and resets the field to its default (empty) state.
Common Mistake
Many developers try to clear the field using an empty string, like this:
DateTimeField := '';
This would not work it will cause an error because an empty string (”) isn’t a valid DateTime value.
Tip: Always use 0DT or CLEAR() when you want to empty a DateTime field in AL. Both methods are valid, reliable, and error free.
FAQ : Emptying a DateTime Field in AL
Following are the important FAQs related to how to Emptying a DateTime field in Business Central.
You can clear it using either of these 2 methods and the same steps defined this post.
0DT represents a blank or default DateTime value – similar to “no date/time assigned.”
No. Assigning an empty string to a DateTime field will cause an error because a string value isn’t valid for a DateTime data type.
Both are correct. Use 0DT when you want to directly assign a value, and CLEAR() when you’re resetting a variable or field.



