CODEDIGEST
Home Articles CodeDigest Tutorials FAQs
Skip Navigation LinksHome » CodeDigest » Get Month Name and Day name for a Date in C#, ASP.Net   You are not logged in.
Search
 

Technologies
 

Get Month Name and Day name for a Date in C#, ASP.Net
Submitted By Satheesh Babu B
On 4/11/2011 7:39:07 AM
Tags: ASP.Net,C#,CodeDigest  

Get Month Name and Day name for a Date in C#, ASP.Net

 

Sometimes, we may need to get the full month name and day name in ASP.Net from a given date.

In this small article, we will achieve this by 2 ways,

  1. The ToString() method of DateTime will acccept the formatting string through which we can display the full month and day name for a given date.

    Response.Write(DateTime.Now.ToString("MMMM"));
    Response.Write("<br>");
    Response.Write(DateTime.Now.DayOfWeek);

  2. The next method is to use DateTimeFormatInfo class of System.Globalization namespace. This class has GetMonthName() and GetDayName() method which gives the full month name and day name.

        DateTimeFormatInfo dinfo = new DateTimeFormatInfo();
        Response.Write(dinfo.GetMonthName(12));
        Response.Write(dinfo.GetDayName(DayOfWeek.Monday));

 

         Include System.Globalization namespace for the above code to work.

 

Happy Coding!!

Do you have a working code that can be used by anyone? Submit it here. It may help someone in the community!!

Recent Codes
  • View All Codes..