Click here to Skip to main content
15,913,115 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to pass input date from DateTimePicker control of Windows form to a function and convert it into DateTime for further programming.

Plese help.


Sheethal
Posted

The value of a datetimepicker can be get by:

DateTime dateTime = dateTimePicker1.Value;
 
Share this answer
 
Comments
Sheethal R A 18-Nov-10 1:30am    
i have tried this.

later to i have to convert this type to DateTime type. But it is not permitting to convert.
JF2015 18-Nov-10 1:32am    
Why convert it later to DateTime type. The DateTimePicker.Value property already gives you the DateTime type - no need to convert it later. If it is 'not permitting', then what is the error you get?
Whats the problem with using:
my_DateTimePicker.Value.ToShortDateString(); ?

Use value property and then you can convert it into desired format. Pass it as a string or date datatype. If needed, use Convert.ToDateTime to convert it back into a date and any specific format.
 
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