Any one please help i need to show the date 03/03/2012 as March 3rd,2012 etc
YYYY-MM-DD (2014-12-01)
For the data load to convert the date to 'yyyymmdd' format, I will use CONVERT(CHAR(8), TheDate, 112). Format 112 is the ISO standard for yyyymmdd.
You can create your own custom format provider to do this:
public class MyCustomDateProvider: IFormatProvider, ICustomFormatter {     public object GetFormat(Type formatType)     {         if (formatType == typeof(ICustomFormatter))             return this;          return null;     }      public string Format(string format, object arg, IFormatProvider formatProvider)     {         if (!(arg is DateTime)) throw new NotSupportedException();          var dt = (DateTime) arg;          string suffix;          if (new[] {11, 12, 13}.Contains(dt.Day))         {             suffix = "th";         }         else if (dt.Day % 10 == 1)         {             suffix = "st";         }         else if (dt.Day % 10 == 2)         {             suffix = "nd";         }         else if (dt.Day % 10 == 3)         {             suffix = "rd";         }         else         {             suffix = "th";         }          return string.Format("{0:MMMM} {1}{2}, {0:yyyy}", arg, dt.Day, suffix);     } } This can then be called like this:
var formattedDate = string.Format(new MyCustomDateProvider(), "{0}", date); Resulting in (for example):
March 3rd, 2012
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