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

Could you plz let me know that hw you get the current date in the datetimepicker? ( I need coding)


i have set short format property on design , but not working
Posted
Updated 23-Jan-13 23:46pm
v2

Please check this.

C#
dateTimePicker1.Value = System.DateTime.Now;
 
Share this answer
 
v2
You may set the format to custom then you will be able to get it as date format.

you can access the current date selected from the date time picker from .Text property in code.
 
Share this answer
 
Comments
Master Vinu 24-Jan-13 6:03am    
i need current date in short format only, .text not working
I tested it in my System.
Setting Format to 'Short/Custom' works fine for showing only Date in the Control.
And if u want to use the current date or selected date from it, then you can use the 'Text' property of control like this:

C#
label1.Text = dateTimePicker1.Text;


It's working fine with me.
Check out.
 
Share this answer
 
Comments
Master Vinu 24-Jan-13 6:10am    
dear all , on form load i need current date is default date in datetimepicker
how to get???
if user login tomorrow then he get tommorows date bydefault on datetimepicker
P_Dash 24-Jan-13 7:21am    
I hope you got your answer.
But dude, by default DateTimePicker control shows current date only.
I don't know if it's working perfectly in your System or not.
But this how this control behave.
string todayDate = DateTime.Now.ToShortDateString();

It will give to just today's date with standard format
 
Share this answer
 
Comments
Member 13538539 24-Dec-22 8:26am    
Read the question carefully.

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