DateTimePicker Format help
Hello,
I need to have my date into a label.text = 03/10/2011
I'm able to do that on my datetimepicker1 but when I try to pass to the text it brings in short date = 3/10/2011
I need the zeros.
Code:
'format the datetimepicker value
Me.DateTimePicker1.CustomFormat = "MM/dd/yyyy"
Me.DateTimePicker1.Format = DateTimePickerFormat.Custom
Me.Label1.Text = Me.DateTimePicker1.Value.ToShortDateString
How can I have the value of label1.text with 03/10/2011 and not 3/10/2011?
thanks,
Kerb
Re: DateTimePicker Format help
ToShortDateString uses the system short date format, so it's nothing to do with your DTP. If you want the same text as is in the DTP then just use the Text property of the DTP. Otherwise, call ToString and pass a custom format string instead of calling ToShortDateString.
Re: DateTimePicker Format help
Thanks JMCilhinney,
that was it,
Me.Label1.Text = Me.DateTimePicker1.Value.ToString("MM/dd/yyyy")
thanks,