How to convert date format to DD-MM-YYYY in C#? I am only looking for DD-MM-YYYY format not anything else.
From mm/dd/yyyy to dd/mm/yyyy To change the date display in Excel follow these steps: Go to Format Cells > Custom Enter dd /mm /yyyy in the available space.
Your answer First, pick the cells that contain dates, then right-click and select Format Cells. Select Custom in the Number Tab, then type 'dd-mmm-yyyy' in the Type text box, then click okay. It will format the dates you specify.
yyyy — Example: 23.06. 2013. dd/MM/yyyy — Example: 23/06/2013. yyyy/M/d — Example: 2013/6/23.
string date = DateTime. ParseExact(SourceDate, "dd/MM/yyyy", CultureInfo. InvariantCulture). ToString("yyyy-MM-dd");
string formatted = date.ToString("dd-MM-yyyy");
will do it.
Here is a good reference for different formats.
According to one of the first Google search hits: http://www.csharp-examples.net/string-format-datetime/
// Where 'dt' is the DateTime object... String.Format("{0:dd-MM-yyyy}", dt);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With