How to display only date with DateTimePicker control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cardei
    New Member
    • Feb 2008
    • 5

    #1

    How to display only date with DateTimePicker control

    Hi, I need some help ... (Visual Basic 2008 Express)
    I have the next line of code :

    Code:
    Form2.Label54.Text = DateTimePicker1.Value
    when I change the date on DateTimePiker control label54 display date an hour.

    I change the format of DateTimePiker to short or custom but i get the same thing.

    I need to display only the date selected.

    Thanks.
  • Zitomd
    New Member
    • Mar 2008
    • 2

    #2
    Originally posted by cardei
    Hi, I need some help ... (Visual Basic 2008 Express)
    I have the next line of code :

    Code:
    Form2.Label54.Text = DateTimePicker1.Value
    when I change the date on DateTimePiker control label54 display date an hour.

    I change the format of DateTimePiker to short or custom but i get the same thing.

    I need to display only the date selected.

    Thanks.
    Form2.Label54.T ext = DateTimePicker1 .Text Would result in Saturday, March 1, 2008 on my form but if your looking to get rid of the weekday then;

    Another option is
    Form2.Label54.T ext = DateTimePicker1 .Value.Date Would result in 3/1/2008

    Otherwise you could build the string
    strDate = DateTimePicker1 .Value.Month
    strDate = strDate & "-" & DateTimePicker1 .Value.Day
    strDate = strDate & "-" & DateTimePicker1 .Value.Year

    Form2.Label54.T ext = strDate Would result in 3-1-2008

    Comment

    • cardei
      New Member
      • Feb 2008
      • 5

      #3
      Thanks a lot Zitomd

      It's what I need

      Comment

      Working...