i am using 4 date n time picker on the form in formate option i manage only date but the
file stored contain date and time but i want only date.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Aug 15, 2012, 11:13 AM
string dateStr = dateTimePicker1.Value.ToString("dd-MMM-yy");
and then slot that into your record.
ta muPosted Aug 15, 2012, 10:57 AM
i just need to formate it
like
M Tayyab 20 Male 16-Aug-12 3:31:27 PM 17-Aug-12 3:31:28 PM 18-Aug-12 3:31:28 PM
this is one record i want
M Tayyab 20 Male 16-Aug-12 17-Aug-12 18-Aug-12
thats it.
VulpesPosted Aug 15, 2012, 9:31 AM
dd/MM/yyyy HH:mm:ss
then one way to get rid of the time element is to apply the String.Split method before you parse it to a DateTime value. For example:
string readFromFile = "15/08/2012 14:00:00"; // if days precede months in your culture
string dateStr = readFromFile.Split(' ')[0];
DateTime date = DateTime.Parse(dateStr);
dateTimePicker1.Value = date;
Another way is to parse it, as it stands, to a DateTime and then use the DateTime.Date property to extract just the date: