Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to convert the date time "06/01/16" to 06/01/2016" in C#

What I have tried:

Not possible to convert to dd-mm-yyyy
Posted
Updated 29-Sep-16 9:43am
Comments
Pete O'Hanlon 29-Sep-16 4:47am    
Your what I have tried section doesn't match your question. Are you storing "06/01/16" as a DateTime, or is it a string? What does your code look like.

try this

C#
string date = DateTime.ParseExact("06/01/16", "dd/MM/yy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy"); //"06/01/2016"
 
Share this answer
 
C#
DateTime original = Convert.ToDateTime("06/01/16");
DateTime converted = Convert.ToDateTime(original.ToString("dd/MM/yyyy"));
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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