Solved

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

Posted on 2006-11-21
4
695 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
[X]
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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

691 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