Solved

Date Format in C#

Posted on 2012-04-13
6
404 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

785 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