[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Why does the month come out as 59 using the following C# code?

Posted on 2012-09-09
Medium Priority
Last Modified: 2012-09-09
I am developing a C# application on a Windows platorm using VS2005.

Why does the month come out as 59 (59/09/2012) using the following C# code?

I copy the following statements into a file represented by variable strFile2 and in the file
the following values are generated.


string[] lines = { "CODEPAGE:850",
                                   "COMMENT:--------------Xcel Report load-------------------",
                                   "GROUP_FIELD_VALUE:" + REPTYR,
                                   "GROUP_FIELD_VALUE:" + DateTime.Now.ToString("mm/dd/yyyy"),
                                   "GROUP_FILENAME:/clientdoc/" + strFile4 };  
                System.IO.File.WriteAllLines(strFile2, lines);
Question by:zimmer9
1 Comment
LVL 75

Accepted Solution

käµfm³d   👽 earned 2000 total points
ID: 38381761
Because "mm" (lowercase) in format strings is minutes (as in time). For months, you need to use uppercase letters:

"GROUP_FIELD_VALUE:" + DateTime.Now.ToString("MM/dd/yyyy"),

Open in new window

For a listing of format specifiers, see:  http://blog.stevex.net/string-formatting-in-csharp/

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question