• I removed the www from the URL, please update your bookmarks and pay attention to the bottom of the screen if using Google Chrome to allow push notifications again.

datetime picker info

hendrikbez

Active member
Joined
Nov 24, 2005
Messages
35
Location
South Afica
Programming Experience
1-3
I have a form with a button, textbox and a datetimepicker.

I want to click on datetimepicker and choose a date, then click on button, then the date should show in the textbox.
After I have click on datetimepicker and then the button ,it shows the date, but in the wrong format.

Here is my code, I am using it in my button code

Code:
DateTimePickerOutDate.Format = DateTimePickerFormat.Custom
DateTimePickerOutDate.CustomFormat = "dd MMMM yyyy"
txtSearchDateOut.Text = DateTimePickerOutDate.Value
The date that I want it to display must be dd mmmm yyyy (09 October 2012), but is shows in the textbox as 10/09/2012 2:43:22 PM

What am I doing wrong, is there someplace that I must change the datetimepicker values as well.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,062
Location
Sydney, Australia
Programming Experience
10+
The Value property of the DateTimePicker returns a DateTime. It's just a DateTime like any other, which no specific knowledge of the DateTimePicker or the format it displays its contents in. If you want the data displayed in the TextBox using the same format as the DateTimePicker then use the Text property of the DateTimePicker, which is already a formatted String, rather than the Value.
 
Top Bottom