Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

18 Experts available now in Live!

Get 1:1 Help Now