views:

179

answers:

3

I want to perform this date check:

The date entered by the user should not be less than 12 months ago from the current date, e.g.

if date_value > '03-apr-2009'

How do I write .NET code to do this?

+1  A: 

DateTime.Now.AddYears(-1)

Simon Svensson
+3  A: 

do you mean something like:

if(date_value > DateTime.Now.AddYears(-1))
{
    //enter code here
}
John Boker
A: 

date_value which i'm entering is in string format

[ as i did casting already as *( (System.DateTime)date_value).ToString("dd-MMM-yyyy")* ]

so now i want to make a comparision with this string (date_value) and DateTime.Now.AddYears(-1))

so can two strings be compared as such ???? (if one date value is > than the other)

OR Should i do any casting for the comparision ?

stack_pointer is EXTINCT
cast the string to DateTime.
Mark
you can also use a TimeSpan if you feel fancy
RobS