Im showing Warrenty_Expires
of product in my view , but sometimes Warrenty_Expires contains value exactly like this 1753-01-01 00:00:00.000
and i want to say if Warrenty_Expires
contains this value should not display it in my view.Can anyone please help me or point me into the right direction :)
This is i end up with but its not working and still showing this value (1753-01-01).
View:
if (Field.WarrentyExpiress.HasValue) //Check for null value
{
//Check if Warrenty contains this value(1753-01-01)
if (Field.WarrentyExpiress.Value.ToString().Contains("1753-01-01"))
{
<td>Not available</td>
}
else
{
<td>@Field.WarrentyExpiress.Value.ToString("MM/dd/yyyy")</td>
}
}
else
{
<td>Not available</td>
}
Model:
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateTime Warrenty_Expires { get; set; }
ViewModel:
public DateTime? WarrentyExpiress { get; set; }