Hi,
I have the following code.
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?