Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get rid of leading spaces in date

Status
Not open for further replies.

EwS

Programmer
Dec 30, 2002
398
US
'6/5/2007' displays as ' 6/ 5/2007' in my dateTimepicker.
How do I get rid of the leading spaces? What custom format can I use?

Thank you.
 
I tried this before:
Format - Short

but it doesn't remove the leading spaces.

Right now I'm using this:
Format - Custom
CustomFormat - MM/dd/yyyy

It displays the date as '06/05/2007', so I don't have a problem with the leading spaces, however I would prefer not to display zeroes.
 
I already tried that before and it displays the date the same as MM/dd/yyyy.
 

You need to code these two lines to get what you want.

Code:
   Me.DateTimePicker1.CustomFormat = "M/d/yyyy"
   Me.DateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom

Hope it helps.

 
Thanks for your suggestion, but I still cannot get it to work. I put that code in the sub that gets executed when the form is loaded and I even tried to put it in the ValueChange event for my DateTimePicker. What am I doing wrong?
 
Have you tried putting the code directly in the Form_Load?

____________ signature below ______________
You are a amateur developer until you realize all your code sucks.
Jeff Atwood

 
Same result -> ' 6/ 5/2007' instead of '6/5/2007'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top