Solved

ASP.NET - VB.NET - How to format date string?

Posted on 2006-11-21
4
686 Views
Last Modified: 2010-05-18
I am pulling a datetime field from a sql server db and am writing it to an html page as follows:

Response.Write("On " & odr("sampledate") & ", blah blah blah!")

It shows up like this:  5/16/2006.

How can I format the date as follows:

1.  May 16, 2006
2.  5/16/06
3.  May 16th

thank you!
0
Comment
Question by:sah18
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
kraffay earned 250 total points
ID: 17989304
1.  Response.Write("On " & String.Format("{0:MMM dd, yyyy}", odr("sampledate"))   & ", blah blah blah!")
2.  Response.Write("On " & String.Format("{0:MM/dd/yy}", odr("sampledate"))   & ", blah blah blah!")
3.  Don't think that's possible?

 
0
 
LVL 9

Author Comment

by:sah18
ID: 17990058
thank you very much!
0
 
LVL 9

Author Comment

by:sah18
ID: 17997606
I know I already awarded points on this, but one clarification:

for format option 1, the month is being truncated to 3 characters only (ex: Apr)... is there a way to get the full month showing up?
thank you again!
0
 
LVL 9

Expert Comment

by:kraffay
ID: 17997857
Here it is:

Response.Write("On " & String.Format("{0:MMMM dd, yyyy}", odr("sampledate"))   & ", blah blah blah!")


ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_vbalr/html/e51b77e6-9c84-48d6-83d8-08aef8cacab1.htm
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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