I have the following code:
examdate = Convert.ToDateTime(ttd.DateCreated).ToString("MMM dd yy");
and it returns Jun 27 18
but I need the following output
Jun 27 '18
so I changed my code to
examdate = Convert.ToDateTime(ttd.DateCreated).ToString("MMM dd 'yy");
and it threw up an error:
Cannot find a matching quote character for the character '''.
You just have to escape the single quote (') inside of the ToString() call.
Simple example:
using System;
public class Program
{
public static void Main()
{
Console.WriteLine(DateTime.Now.ToString("MMM dd \\'yy"));
}
}
Result:
Jun 27 '18
Fiddle Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With