Click here to Skip to main content
15,920,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello;

how to compare two dates in asp.net
Posted

The DateTime class has a Compare function which accepts two datetime variables as arguments.
 
Share this answer
 
Comments
Espen Harlinn 17-Mar-11 19:28pm    
My 5 - nice and simple
Albin Abel 18-Mar-11 0:27am    
Thanks Espen Harlinn
The fact that it's ASP.Net makes no difference at all.

C#
if (thisDate >= thatDate)
{
}


I wrote a Tip/Trick that allows you to compare any combination of DateTime properties. You might find it useful:

Partial DateTime Object Equality[^]
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 17-Mar-11 13:56pm    
Simple as that, and a good reference, a 5.

John, remember this dude who voted 1 for your answer of flicker? a long stupid discussion yesterday?
http://www.codeproject.com/Answers/169644/Flickering-Transparency-and-BackgroundImages.aspx
Do you remember?

I made him!

I fact, your answer and Albin's answers were correct. I found most stupid mistake Josh made. Can you imagine what? He enabled double buffering on Form but had buffering on other control, blindly assuming the Form would cure the control! :-) :-). I spotted it and asked him three times until he confessed he did this stupid thing.
And imagine what? Now he is trying to play the role of the... offended one (I only said: "Damn! Be logical!"), I think, down-voted again. What a personality!

It's getting funny; take a look if you still have a hart for that... :-)

--SA
Albin Abel 18-Mar-11 0:26am    
It is simple and a good link. 5
vpsingh136 7-Jan-12 7:50am    
i have to compare my date with database then the condition if true how it validates in asp.net
vpsingh136 7-Jan-12 7:51am    
i have to compare my date with database then the condition if true how it validates in asp.net pls fwd me coding to the following mail
vpsingh136@gmail.com

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900