A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
Hello @Corey Fleig and thank you for your question.
When formatting the date, you can use the null-conditional operator (?.) to call ToShortDateString() only when Birth has a value:
var dob = Birth?.ToShortDateString();
Just make sure that Birth is declared as a nullable DateTime (DateTime?) in your model as well.
Also, depending on what you want to do with dob, you could consider using the null-coalescing operator (??) to provide a fallback value, or use an explicit HasValue check:
var dob = Birth?.ToShortDateString() ?? "";
var dob = Birth.HasValue
? Birth.Value.ToShortDateString()
: "";
I hope this helps, and please let me know if you have other questions.
If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation. Thank you.