Custom date format

Posted on 2013-05-23
Medium Priority
Last Modified: 2013-05-28
Hi Experts,
I have a date field in mm/dd/yyyy format in database.  In my aspx page I need to display in 24/MAY/2013 format.  So I am using DataFormatString="{0:dd/MMM/yyyy}".  But it displays 24/May/2013.  How can I display as 24/MAY/2013 or month changed to Uppercase?

Thank you very much for your help and time.
Question by:RadhaKrishnaKiJaya
  • 3
  • 2
LVL 30

Expert Comment

ID: 39192630

            DateTime d = new DateTime(2013, 5, 22);

            string ds = d.ToString("{dd/MMM/yyyy}").ToUpper();

Open in new window


Author Comment

ID: 39192649
Thank you anarki_jimbel,
I need it in a gridview.  Currently I am using DataFormatString="{0:dd/MMM/yyyy}", but the month is always in proper case.  I need month uppercase such as 23/MAY/2013.  Thank you again!
LVL 30

Assisted Solution

anarki_jimbel earned 1500 total points
ID: 39192787

Accepted Solution

RadhaKrishnaKiJaya earned 0 total points
ID: 39193207
This one returns months as Jan, Feb etc.  I need JAN, FEB etc.  I found the solution already.  Here is what I am doing in DataBind and worked fine.  Thank you for you quick response and time.

string BirthDay = e.Row.Cells[0].Text;

e.Row.Cells[0].Text = BirthDay.Substring(0, 2) + "/" + StartDate.Substring(3, 3).ToUpper() + "/" + StartDate.Substring(7, 4);.

Author Closing Comment

ID: 39200685
Thank you.

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
An ASP.NET Web Form User Control is not newly introduced in ASP.NET. In fact, it was an old technology yet still playing a role to generate web content, especially when we want to use it to have a better and easy way to control part of the web conte…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
From store locators to asset tracking and route optimization, learn how leading companies are using Google Maps APIs throughout the customer journey to increase checkout conversions, boost user engagement, and optimize order fulfillment. Powered …

624 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