when i run the following code:
DateTime.ParseExact("03-08-2013", "dd-mm-yyyy", null).ToString("dd-MMM-yyyy") I get "03-jan-2013"
why does it convert august to january?
Lowercase mm means minute instead of month, so this should work as desired:
DateTime.ParseExact("03-08-2013", "dd-MM-yyyy", null).ToString("dd-MMM-yyyy") Output: 03-Aug-2013
You have "MMM" in the ToString() method, which means you will get a 3-letter month abbreviation. See a helpful article on the topic at http://www.csharp-examples.net/string-format-datetime/.