I have 1 datetime field that is not nullable and 1 that is nullable. I can use the following code with the non nullable one :
c.StartDate.Day.ToString() + "/" +
c.StartDate.Month.ToString() + "/" +
c.StartDate.Year.ToString()
But when I try to do this with the nullable one, I get the error :
‘System.Nullable’ does not contain a definition for ‘Day’ and no extension method ‘Day’ accepting a first argument of type ‘System.Nullable’ could be found (are you missing a using directive or an assembly reference?)
How do I get the Day, Month, Year of a nullable datetime?
You’ll have to use the
.Valueproperty on your nullable:After checking for
null, you could: