0

I want to check that the expiration date is greater than another date.

[DisplayFormat(DataFormatString = "0:yyyy/MM/dd", ApplyFormatInEditMode = true)]
public DateTime? Date { get; set; }

[DisplayFormat(DataFormatString = "0:yyyy/MM/dd", ApplyFormatInEditMode = true)]
public DateTime? Expiration { get; set; }

How do I do this?

Jamie Rees
  • 7,973
  • 2
  • 45
  • 83
  • Can you please translate your question to English? – Soner Gönül Dec 30 '15 at 08:12
  • 5
    Modified as per my limited knowledge of la lingua Francais. Knowledge which consists of two years at school some *cough/sputter* decades ago and a week in Paris mid this year so, for all I know, OP may have been calling my parentage into question :-) – paxdiablo Dec 30 '15 at 08:17
  • I'm french and i have to say that your translation is good :) – Guillaume Dec 30 '15 at 12:11

2 Answers2

1

You need to create a custom validator to check your different dates using ValidationAttribute.

Take a look of this link.

Community
  • 1
  • 1
Guillaume
  • 844
  • 7
  • 25
1

for example

DateTime date = DateTime.Now;
DateTime expiration = DateTime.Now.AddDays(3);
if (expiration > date) 

you can compare dates like this

Redwerk
  • 56
  • 2