Click here to Skip to main content
14,937,435 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am creating an windows application in that i used two datetimepicker.If i am select any date in first datetimepicker then in second datetimepicker display future date which is 6 month differences.following is example

if i select date in first datetimepicker i.e. 8/9/2012 (mm:dd:yyy) then

in second datetimepicker display date i.e. 2/8/2013(mm:dd:yyy) there is must 6 month difference in second datetimepicker.
[no name] 8-Aug-12 10:11am
Why are you reposting when you have an answer to your question?

You should use TimeSpan and add 6 months to the date time variable :)
Here is the code - dateTimePicker2.Value = Convert.ToDateTime(dateTimePicker1).AddMonths(6);
Manohar Khillare 8-Aug-12 10:39am
if datetimepicker2 on different page how can i do this
Zoltán Zörgő 16-Aug-12 12:57pm
"page"? You mean you are in ASP.NET?
Rajesh Varma Buddaraju 9-Aug-12 2:40am
Create a public static variable in the required page and fill it from the source page.
Ank_ush 16-Aug-12 12:26pm
Not Completely Correct....
just add the 6 months time to your 1st datetimepicker..

if you dont understand this, then pls show the code..
You were answered here yesterday, why to repost? how to calculate date difference in windows application[^]
Try This:-

dateTimePicker2.Value = dateTimePicker1.Value.AddMonths(6);

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