datetimepicker formats

Posted on 2005-04-26
Last Modified: 2012-06-27

I hope this is a stupid question and I will be able to get on with life quickly!

It seems that no matter how I specify a format for a datetimepicker control, it shows up with the date as well as the time.

Is there some obvious oversight that causes this?  I can give examples but am hoping that this is an easy one.

Question by:zoseri
    LVL 5

    Accepted Solution

    Hi zoseri,

    The following works fine for me:

                timeControl = new DateTimePicker();
                timeControl.Format = DateTimePickerFormat.Custom;
                timeControl.CustomFormat = "HH:mm";
    LVL 21

    Assisted Solution

    The same can be done in the design view - select your control, hit F4 and in the properties set Format to Custome and in the CustomFormat type in HH:mm:ss or whatever


    Author Comment

    Maybe my problem is that I am putting the date into a textbox?

    For some of my date fields, the date is FYI only so I put it into
    a ReadOnly textbox...when I do a ToString on the date, even
    though a Custom Format is used, does the format not get
    taken into account?

    Thx again

    Author Comment

    Thanks guys.  It seems after all that the problem was when I tried to put the data into a the datetimepickers do work fine and I just strip off any unwanted parts in the string sent to textbox...

    I'll split points anyway

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    27 Experts available now in Live!

    Get 1:1 Help Now