Solved

Date Format in C#

Posted on 2012-04-13
6
409 Views
Last Modified: 2012-04-17
Hi There,

How to get this type of date format?

Vlaue from DB: 2012-04-13 00:00:00.000 to April 13, 2012 (Friday).

Thanks.
0
Comment
Question by:theartha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 37844729
DateTime dt = <value from db>

dt.ToString("MMMM dd, yyyy") + "(" + dt.ToString("dddd") + ")";


See this for more Info:
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
0
 
LVL 13

Expert Comment

by:Ashok
ID: 37844735
Try

DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123);

String.Format("{0:MMMM dd, yyyy (dddd)}", dt);

HTH
Ashok
0
 

Expert Comment

by:nerdeasy
ID: 37844739
Here is some sample code:

DateTime dateValue = DateTime.Parse("2012-04-13 00:00:00.000");
Console.WriteLine(dateValue.ToString("MMMM d, yyyy (dddd)"))

Open in new window


That should help
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

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

 
LVL 13

Expert Comment

by:Ashok
ID: 37845197
DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123);
      string s1 = dt.ToString("MMMM d, yyyy (dddd)");
      string s2 = dt.ToString("MMMM dd, yyyy (dddd)");

s1 will give 1 digit for a day.
s2 will give you 2 digits for a day.

HTH
Ashok
0
 
LVL 12

Expert Comment

by:Anuradha Goli
ID: 37846021
You can try
DateTime dt = DateTime.Parse("2012-04-13 00:00:00.000");
Console.WriteLine(dt.ToString("MMMM d, yyyy (dddd)"))
0
 

Expert Comment

by:seenupegada
ID: 37846824
Try this,

in <itemtemplate>

<%#Eval("Doj", "{0:MMMM d, yyyy(dddd)}")%>
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

623 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