Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i m working in asp.net.
if (DateTime.Now <= MailTime) //condition in apllication taken where MailTime =7:00 pm taken in window configuration.using in apllication
i want only match time in minute but by default system are matching HH:MM:SS and return to else at any how i want to enter in if loop
pls help me
Posted
Updated 1-Feb-12 1:49am
v2
Comments
Rajesh Anuhya 1-Feb-12 7:50am    
Question not clear, can you elaborate it more..

Try This

C#
DateTime d = DateTime.Parse((DateTime.Now.ToString("hh:mm")));
       if (d <= MailTime)
       {
           Response.Write("yes");
       }
 
Share this answer
 
Convert.ToDateTime(DateTime.Now.ToString("hh:mm"))


First, get just the minute and hours and then convert to a DateTime object and then compare to your other datetime object. There are lots of ways you can do this, this is just one example.
 
Share this answer
 
v2
Comments
Rajesh Anuhya 1-Feb-12 8:10am    
Edited: code tags added
--RA

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