Solved

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

Posted on 2006-11-21
4
684 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now