Solved

Custom date format

Posted on 2013-05-23
5
401 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
ID: 39192630
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
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!
0
 
LVL 29

Assisted Solution

by:anarki_jimbel
anarki_jimbel earned 500 total points
ID: 39192787
0
 

Accepted Solution

by:
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);.
0
 

Author Closing Comment

by:RadhaKrishnaKiJaya
ID: 39200685
Thank you.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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