I have a date picker (DateTimePicker) in my application. Currently, when a user selects the desired date, the outputed result reads as follows:
Code:
private void btnEnter_Click(object sender, EventArgs e)
{
string date = startDatePicker.Value.ToString();
dateStart.Text = date;
}
Output (what dateStart becomes)
07/16/2012 1:18 PM
However, I need the date to be formated like this:
2012/07/16
Also, I don’t need the time to show up. Is there a way to change the date format and stop the time from showing up?
use custom format
http://msdn.microsoft.com/en-us/library/system.windows.forms.datetimepicker.customformat.aspx