Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: DateTimeUpDown Custom Format

$
0
0
Hi,

I have the following code.
        public static string DateOnly(DateTimePicker dtp)
        {
            DateTimePicker myDTP = new DateTimePicker();
            myDTP.Format = DateTimeFormat.Custom;
            myDTP.FormatString = "yyyy-MM-dd";
            myDTP.Value = dtp.Value;
            return myDTP.Value.ToString();
        }
If my dtp.Value is "12/21/1999 01:02:03 PM", I want to return only "1999-12-21", but the entire original Value is being returned. I tried moving myDTP.Value = dtp.Value above the Format setting, but it made no difference. I verified the FormatString works in the provided DateTime Sample. What am I doing wrong?

Viewing all articles
Browse latest Browse all 4964

Trending Articles