I want to convert a C# DateTime to \"YYYYMMDDHHMMSS\" format. But I don\'t find a built in method to get this format? Any comments?
You've just got to be careful between months (MM) and minutes (mm):
DateTime dt = DateTime.Now; // Or whatever
string s = dt.ToString("yyyyMMddHHmmss");
(Also note that HH is 24 hour clock, whereas hh would be 12 hour clock, usually in conjunction with t or tt for the am/pm designator.)
If you want to do this as part of a composite format string, you'd use:
string s = string.Format("The date/time is: {0:yyyyMMddHHmmss}", dt);
For further information, see the MSDN page on custom date and time formats.