.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

Validate DateTimePicker Control in C#.Net

Posted By: Narayanan     Posted Date: August 16, 2012    Points:5   Category :C#
Hi All,
How to set One DateTimePicker MinDate and MaxDate?
This is code for Set MinDate or MaxDate Property of One DateTimePicker
DateTimePicker1.MinDate = "04/01/2012";
Or
DateTimePicker1.MaxDate = "03/31/2013";

But I want to validate selected value.
Note:Selected Value should not Exceed MinDate and MaxDate Value.Please help Me


Responses
Author: p sai prasant             
Posted Date: August 19, 2012     Points: 20   

hi Narayan,

please check this link given below :

http://www.c-sharpcorner.com/UploadFile/scottlysle/DtpValidation03252007045710AM/DtpValidation.aspx

:)

Author: Narayanan             
Posted Date: August 20, 2012     Points: 20   

Hi,
Thanks.

Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
Author: Santosh             
Posted Date: August 22, 2012     Points: 20   

Hi

U can just compare the value useing >< conditions

if ((DateTimePicker1.value)<(DateTimePicker1.Maxdate.value)) and ((DateTimePicker1.value)>(DateTimePicker1.Mindate.value))

"Sucess"
else
"Check the selected Date"

Author: Baimey Rajesh             
Posted Date: August 28, 2012     Points: 20   

Hi Narayan ,

Did u get answer to ur question??

Baimey

Author: Baimey Rajesh             
Posted Date: August 28, 2012     Points: 20   

Please try this

there is a datetime

subract method

.
If the result is negetive i.e.<0 then the dateTime1 is after dateTime2.

TimeSpan span = dateTime2.Subtract(dateTime1);


You can use an AND clause and check both. Please see if it helps.

Thanks
Baimey

Author: Jack Smith             
Posted Date: September 03, 2012     Points: 20   

This is code for Set MinDate or MaxDate Property of One DateTimePicker

DateTimePicker1.MinDate = "04/01/2012";

Or

DateTimePicker1.MaxDate = "03/31/2013"

Click Here for More Information about .Net Developer of India
Author: N SRILATHA             
Posted Date: September 24, 2012     Points: 20   

Hi,


No need to write any coding.You set min date and max Date.Then it will automatically validate and allow in b/w max date and min date only.

Author: Clintonzz             
Posted Date: March 11, 2014     Points: 20   

I want to try a UI datetime picker:

http://www.kettic.com/winforms_ui/csharp_guide/editor_datetime_picker.shtml

and I also feel confused about the same question as yours.



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend