Results 1 to 4 of 4

Thread: Date Time Picker doesn't show Date & Time

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    Date Time Picker doesn't show Date & Time

    I have a datetimepicker control where I want to show both the date and time but so far have not been able to do so.

    I have the properties format set to custom and then through code I am trying to do this:
    VB Code:
    1. ' Format DateTime
    2.         dtpShow.Value = CDate(dtShowDateTime.ToString("u"))
    3.         dtpStart.Value = CDate(dtStartDateTime.ToString("u"))
    4.         dtpEnd.Value = CDate(dtStopDateTime.ToString("u"))

    At run time the control is only showing Long or Short depending on the properties. I want to show it like this: 2007-9-18 00:00:00

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Date Time Picker doesn't show Date & Time

    When you set the format to custom, also set the CustomFormat property to the format you want.

    To match the example you gave, use a CustomFormat of "yyyy-M-dd hh:mm:ss"

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Date Time Picker doesn't show Date & Time

    You need to set the CustomFormat property of your datetimepicker control
    This should do it:
    Code:
            DateTimePicker1.Format = DateTimePickerFormat.Custom
            DateTimePicker1.CustomFormat = "yyyy-M-dd HH:mm:ss"

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    Re: Date Time Picker doesn't show Date & Time

    Thank you that worked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width