Solved

Date Format in C#

Posted on 2012-04-13
6
407 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 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...

713 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