Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In database records as follows

MedicalEntryDate
1st Oct 2014

I want to validate MedicalEntryDate should be greater than the Today's Date.


for that how can i do in asp.net using c#.
Posted
Comments
Nelek 7-Oct-14 5:53am    
Shouldn't be greater or equal? If a patient entries today you can not input tomorrow to return true, can you?

Use DateTime.Now[^] for the comparison.
Depending on your needs, either
  • Retrieve the medical entry date from the database and compare it with Now.

Or
  • Write a SQL query using Now as the comparison parameter.
 
Share this answer
 
Hello,

Try this code and if the result is positive then database date smaller than today's date and vice versa.

DateTime date = Convert.ToDateTime("01 / 01 / 1990");
TimeSpan ts = DateTime.Now - date;
lblMsg.Text = Convert.ToString(ts.TotalDays);


thanks.
 
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