how to compare dates in c#..........

Posted by Rimjhim4 under C# on 4/2/2012 | Points: 10 | Views : 1412 | Status : [Member] | Replies : 2
i want to compare current date with another date pick from calender........
how to compare dates in c#..........
tell me...........




Responses

Posted by: Rajni.Shekhar on: 4/2/2012 [Member] Bronze | Points: 25

Up
0
Down
check it...

DateTime dt = new DateTime(2012, 03, 29);
DateTime todate = System.DateTime.Now;
Response.Write(dt.CompareTo(todate));

it will return -1 if given date is smaller or equal to current date.
and will return 1 if given date is greater than current date.

Thanks,
Rajni Shekhar

Rimjhim4, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/3/2012 [Member] Bronze | Points: 25

Up
0
Down
Rimjhim4
DateTime d1= new DateTime(04/11/2011);
DateTime d2= new DateTime(07/11/*2011;
int result = DateTime.Compare(d1, d2);

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Rimjhim4, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response