Format DateTime in the form: "W E D N E S D A Y   9/11"

Posted on 2008-11-19
Medium Priority
Last Modified: 2012-05-05
I am using .NET/C#. I have DateTime values I'm pulling from a DB. For a given DateTime value, I want the day formatted with a space between each letter of the day. Then I want two spaces, then I want a numeric month and day divided by a slash. Examples:

"W E D N E S D A Y   9/11"
"F R I D A Y   9/13"

The spacing on the lettering should ideally be done with StringBuilder or whatever so this doesn't suffer massive perf issues.

I'm sure I could hack this out myself but one of you geniuses know this straight off the top of your head, hmm?

Thanks much for any help you can offer.
Question by:kennethfine
1 Comment
LVL 12

Accepted Solution

jandromeda earned 2000 total points
ID: 23000644
Well this is what I can come up with.
DateTime time = DateTime.Today;
			string monthAndDate = time.ToString("MM/dd");
			string day = time.DayOfWeek.ToString();
			char[] arr = day.ToCharArray();
			day = string.Empty;		
			foreach (char c in arr)
				day = string.Concat(day, c.ToString(), " ");
			Console.WriteLine(string.Concat(day, " ", monthAndDate));

Open in new window


Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.
Suggested Courses

864 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