Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

How do I write this date format string?

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

Thanks
0
bmanmike39
Asked:
bmanmike39
2 Solutions
 
Fernando SotoCommented:
Try it like this.

DateTime dt = new DateTime(2010, 8, 1)
string printedDate = dt.ToString("MMM d");
0
 
Reza RadCommented:
Response.Write((new DateTime(2010,1,8).ToString("MON dd"));
0
 
Reza RadCommented:
sorry,try this one:
Response.Write((new DateTime(2010,1,8).ToString("MMM dd"));

0
Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
vb_studentCommented:
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"
ect.
ect.
        End Select

display_date += pulled_date.day

hope this helps.
0
 
Reza RadCommented:
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"));
0
 
bmanmike39Author Commented:
Thanks!
0
 
Fernando SotoCommented:
Not a problem, always glad to help.  ;=)
0

Featured Post

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now