Click here to Skip to main content
15,885,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai all,

I have to DateTime Fileds(dateTime1 and DateTime2)
I want to check weather the current Date and Time is in between dateTime1 and dateTime2

I tried this Code but didn't get what i need

if ((DateTime.Now > dateTime1) && (DateTime.Now < dateTime2))
       {
            //
       }


where dateTime1 is lessthan current Date and dateTime2 is greaterthan current Date

How can I do this? Please help me..
Posted
Updated 23-Aug-11 20:13pm
v2
Comments
Prerak Patel 24-Aug-11 2:09am    
What is the value of dateTime1 and dateTime2?
version_2.0 24-Aug-11 2:16am    
updated..
dan!sh 24-Aug-11 2:10am    
What do you mean it is not working? These operators do work for DateTime struct.
version_2.0 24-Aug-11 2:25am    
thanks for that info..

1 solution

Your code is perfectly fine for date comparison. Check the values of dateTime1 and dateTime2.
 
Share this answer
 

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