---
title: "How to check if a DateTime field is not null or empty?"  
description: "How to check if a DateTime field is not null or empty?"  
author: "Anonymous User"  
published: 2014-04-01  
updated: 2019-04-30  
canonical: https://www.mindstick.com/forum/2006/how-to-check-if-a-datetime-field-is-not-null-or-empty  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How to check if a DateTime field is not null or empty?

I am very new in C# and I have a doubt.

In an [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) on which I am working I found something like it in the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):

if (![String](https://www.mindstick.com/articles/1527/string-split-in-c-sharp).IsNullOrEmpty(u.nome))

This code simply [check if](https://www.mindstick.com/forum/12878/how-to-check-if-an-asp-dot-net-file-upload-control-has-a-file-in-jquery) the nome [field](https://www.mindstick.com/forum/160867/does-mindstick-provide-training-for-field-marketing) of the u object is not an empty\[null](https://www.mindstick.com/forum/33922/how-to-use-null-coalescing-operator-in-c-sharp) string.

Ok this is very clear for me, but what can I do to check it if a field is not a string but is [DateTime](https://www.mindstick.com/forum/12949/how-to-validate-if-a-datetime-field-is-not-null-empty) object?

## Replies

### Reply by Alice Taylor

Post is removed by the Admin.

### Reply by tracking usps

Post is removed by the Admin.

### Reply by Pravesh Singh

Hi Ankit,\

If you declare a DateTime, then the default value is DateTime.MinValue, and hence you have to [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) it like this:

DateTime dat = new DateTime();

if (dat==DateTime.MinValue)

{

//unassigned

}

If the DateTime is nullable, well that's a different story:

DateTime? dat = null;

if (!dat.HasValue)

{

//unassigned

}


---

Original Source: https://www.mindstick.com/forum/2006/how-to-check-if-a-datetime-field-is-not-null-or-empty

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
