Solved

Custom date format

Posted on 2013-05-23
5
393 Views
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.
0
Comment
Question by:RadhaKrishnaKiJaya
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:anarki_jimbel
Comment Utility
Try:

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

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

Open in new window

0
 

Author Comment

by:RadhaKrishnaKiJaya
Comment Utility
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!
0
 
LVL 29

Assisted Solution

by:anarki_jimbel
anarki_jimbel earned 500 total points
Comment Utility
0
 

Accepted Solution

by:
RadhaKrishnaKiJaya earned 0 total points
Comment Utility
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);.
0
 

Author Closing Comment

by:RadhaKrishnaKiJaya
Comment Utility
Thank you.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now