Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have created a app which can store data into excel sheets.
it works. but it stores time as well.
how can i remove time part and store date only.
C#
DateTime result = dateTimePicker1.Value.Date;
            string date1 = result.ToString();
Posted
Comments
Sergey Alexandrovich Kryukov 15-Nov-14 0:18am    
Why? Do you store date as string?
—SA
Dusara Maulik 15-Nov-14 0:52am    
which method you are using to store data into excel?
Hemas Ilearn 15-Nov-14 1:03am    
String date1...
BillWoodruff 15-Nov-14 3:54am    
Since Excel stores DateTime objects as 64-bit floating point, you would actually save memory if you stored the C# DateTime as an Excel DateTime.

If you are interested in this approach, let me know (here), and I'll post an example.

Use result.ToShortDateString()
 
Share this answer
 
result.ToString("dd.MM.yyyy");




OutPut : 15/11/2014



Place your date format as above syntax......

Please mark it as Answer if it is useful to u
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900