Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi Im new to c#.. I have String 890724. // formate yy/mm/dd
But i want this string to be displayed in 240784 // formate dd/mm/yy


if any help pls
Posted
Comments
♥…ЯҠ…♥ 27-Dec-13 5:56am    
final output 240784 or 240789?

Try this
C#
string output = DateTime.ParseExact("890724","yyMMdd",null).ToString("ddMMyy");

Happy Coding!
:)
 
Share this answer
 
Comments
♥…ЯҠ…♥ 27-Dec-13 6:12am    
Deserves 5+, nice
Aarti Meswania 27-Dec-13 6:21am    
Thank you! :)
[no name] 27-Dec-13 7:58am    
nice
Aarti Meswania 27-Dec-13 8:02am    
Thank you! :)
The below part of code might be helpful

C#
string str, resStr;
str = "890724"; //// formate yy/mm/dd
resStr = str.Substring(4, 2) + str.Substring(2, 2) + str.Substring(0, 2); //format dd/mm/yy
Response.Write(resStr);
 
Share this answer
 
Comments
♥…ЯҠ…♥ 27-Dec-13 6:10am    
Nice one.... short and sweet
I'd suggest you look at using String.Substring and a StringBuilder - look them up

'g'
 
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