# Setting a DateTime Field to Blank

**URL:** <https://www.epiusers.help/t/setting-a-datetime-field-to-blank/78371>\
**Category:** Epicor ERP 10\
**Tags:** customization\
**Created:** [May 6, 2021, 11:01am UTC](https://www.epiusers.help/t/setting-a-datetime-field-to-blank/78371 "2021-05-06T11:01:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aarong](https://www.epiusers.help/user_avatar/www.epiusers.help/aarong/32/101218_2.png) [@aarong](https://www.epiusers.help/u/aarong)\
**Post date:** [May 6, 2021, 11:01am UTC](https://www.epiusers.help/t/setting-a-datetime-field-to-blank/78371/1 "2021-05-06T11:01:38Z")

</div>

Hi All,

I’m trying to set a DateTime field to blank but can’t seem to work out how to do it.

Any ideas?

Here is the code I’ve been working with.

```auto
private void UD100Form_BeforeToolClick(object sender, Ice.Lib.Framework.BeforeToolClickEventArgs args)
	{
		
		switch (args.Tool.Key)
		{
			case "PrintTool":
				if (this.txtKeyField.Text == string.Empty)
				{
					EpiMessageBox.Show("You need a Load Number");
					return;
				}
					LaunchFormOptions lfo = new LaunchFormOptions();
					lfo.IsModal = false;
					lfo.ContextValue = this.txtKeyField.Text;
					ProcessCaller.LaunchForm(oTrans, "OMRM001", lfo);
				break;
			case "ToolBtnUnlockSales":
				if (!string.IsNullOrEmpty(edvUD100.dataView[edvUD100.Row]["EstimatedDateMth_c"].ToString()) && ((DateTime?)edvUD100.dataView[edvUD100.Row]["EstimatedStampDate_c"]).HasValue)
				{
					DialogResult dialogResult = EpiMessageBox.Show("Are you sure you want to unlock Sales? This will clear the information!","Sales Unlock", MessageBoxButtons.YesNo);
					if (dialogResult == DialogResult.Yes)
					{
						edvUD100.dataView.Table.Rows[0]["AcctsConfirm_c"] = false;
						edvUD100.dataView.Table.Rows[0]["EstimatedDateMth_c"] = string.Empty;
						//edvUD100.dataView.Table.Rows[0]["EstimatedStampDate_c"] = default(DateTime);
						edvUD100.dataView.Table.Rows[0]["EstimatedStamp_c"] = string.Empty;
						epiShape_SalesOffice.Visible = false;
						return;
					}
					EpiMessageBox.Show ("There is no data for me");
				}

				break;

```

I’ve commented it out at the moment as it’s causing massive issues, any thoughts? The field name is `EstimatedStampDate_c` but there is others that use `Date` format.

Kind regards,  
Aaron.

---

<div class="post-metadata">

**Author:** ![tsmith](https://www.epiusers.help/user_avatar/www.epiusers.help/tsmith/32/64774_2.png) [@tsmith](https://www.epiusers.help/u/tsmith)\
**Post date:** [May 6, 2021, 11:03am UTC](https://www.epiusers.help/t/setting-a-datetime-field-to-blank/78371/2 "2021-05-06T11:03:38Z")

</div>

A “blank” date should be the value `null`. Try doing:

```cs
edvUD100.dataView.Table.Rows[0]["EstimatedStampDate_c"] = null;

```

---

<div class="post-metadata">

**Author:** ![aarong](https://www.epiusers.help/user_avatar/www.epiusers.help/aarong/32/101218_2.png) [@aarong](https://www.epiusers.help/u/aarong)\
**Post date:** [May 6, 2021, 11:04am UTC](https://www.epiusers.help/t/setting-a-datetime-field-to-blank/78371/3 "2021-05-06T11:04:58Z")

</div>

You can’t null a date field I don’t believe…

---

<div class="post-metadata">

**Author:** ![aarong](https://www.epiusers.help/user_avatar/www.epiusers.help/aarong/32/101218_2.png) [@aarong](https://www.epiusers.help/u/aarong)\
**Post date:** [May 6, 2021, 11:06am UTC](https://www.epiusers.help/t/setting-a-datetime-field-to-blank/78371/4 "2021-05-06T11:06:09Z")

</div>

![image](https://www.epiusers.help/uploads/default/original/3X/b/9/b9b2f51bd1a4f23dd210d75a00155dba9860bdb9.png)

---

<div class="post-metadata">

**Author:** ![aarong](https://www.epiusers.help/user_avatar/www.epiusers.help/aarong/32/101218_2.png) [@aarong](https://www.epiusers.help/u/aarong)\
**Post date:** [May 6, 2021, 11:07am UTC](https://www.epiusers.help/t/setting-a-datetime-field-to-blank/78371/5 "2021-05-06T11:07:52Z")

</div>

Could of just used, `DBNull.Value`.

Sorry for this pointless post…

---

<div class="post-metadata">

**Author:** ![tsmith](https://www.epiusers.help/user_avatar/www.epiusers.help/tsmith/32/64774_2.png) [@tsmith](https://www.epiusers.help/u/tsmith)\
**Post date:** [May 6, 2021, 11:08am UTC](https://www.epiusers.help/t/setting-a-datetime-field-to-blank/78371/6 "2021-05-06T11:08:37Z")

</div>

I think that’s the most helpful error message I’ve ever seen…

---

<div class="post-metadata">

**Author:** ![aarong](https://www.epiusers.help/user_avatar/www.epiusers.help/aarong/32/101218_2.png) [@aarong](https://www.epiusers.help/u/aarong)\
**Post date:** [May 6, 2021, 11:09am UTC](https://www.epiusers.help/t/setting-a-datetime-field-to-blank/78371/7 "2021-05-06T11:09:51Z")

</div>

I thought that was as well… Normally they’re like riddles… 😃
