Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Date Format in C#

Posted on 2012-04-13
6
Medium Priority
?
416 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
6 Comments
 
LVL 41

Accepted Solution

by:
Kyle Abrahams earned 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

782 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