How do I write this date format string?

Posted on 2010-01-09
Medium Priority
Last Modified: 2013-12-17
I need to display the following date  8/1/2010  as  August 1  only

When I use the long date format {0:D}  I get day of the week, month, day, and year

BTW the date is pulled from a db

Question by:bmanmike39
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
LVL 63

Accepted Solution

Fernando Soto earned 1000 total points
ID: 26274655
Try it like this.

DateTime dt = new DateTime(2010, 8, 1)
string printedDate = dt.ToString("MMM d");
LVL 30

Expert Comment

by:Reza Rad
ID: 26274662
Response.Write((new DateTime(2010,1,8).ToString("MON dd"));
LVL 30

Expert Comment

by:Reza Rad
ID: 26274666
sorry,try this one:
Response.Write((new DateTime(2010,1,8).ToString("MMM dd"));

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.


Expert Comment

ID: 26274733
sadly there are no Month, Day formats built into VB but there is Month, Day, YYYY you can change the way it will display the date by doing somthing like this.

dim pulled_date as date = data_field_value

dim display_date as string
        Select Case pulled_date.Month
            Case 1
                display_date = "january"
            Case 2
                display_date = "febuary"
        End Select

display_date += pulled_date.day

hope this helps.
LVL 30

Assisted Solution

by:Reza Rad
Reza Rad earned 1000 total points
ID: 26274780
this will show month with only 3 first characters :
Response.Write((new DateTime(2010,1,8).ToString("MMM dd"));

but this will show full months names:
Response.Write((new DateTime(2010,1,8).ToString("MMMM dd"));

Author Closing Comment

ID: 31675034
LVL 63

Expert Comment

by:Fernando Soto
ID: 26274889
Not a problem, always glad to help.  ;=)

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 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