Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 105,764 VB.NET Programmers for FREE! Ask your question and get quick answers from experts. There are 1,632 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Changing date format

 
Reply to this topicStart new topic

Changing date format

hoehn_sj
post 1 Jul, 2008 - 08:25 AM
Post #1


New D.I.C Head

*
Joined: 9 Jun, 2008
Posts: 5


My Contributions


I'm new at this but I'm trying to display a date picked by the datetimepicker in a text box, but I want to change the format to long dates, all caps, and trim it down to just MMM DD YYYY. Here's what I have so far

CODE
TextBox1.Text = DateTimePicker1.Value.AddDays(7).ToLongDateString.ToUpper



This gives me everything I need except that the day of the week is also displayed.
User is offlineProfile CardPM

Go to the top of the page


jayman9
post 1 Jul, 2008 - 08:48 AM
Post #2


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,241



Thanked 21 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


Try using the ShortDateString instead.

CODE

DateTimePicker1.Value.AddDays(7).ToShortDateString.ToUpper
User is offlineProfile CardPM

Go to the top of the page

hoehn_sj
post 1 Jul, 2008 - 09:14 AM
Post #3


New D.I.C Head

*
Joined: 9 Jun, 2008
Posts: 5


My Contributions


QUOTE(jayman9 @ 1 Jul, 2008 - 08:48 AM) *

Try using the ShortDateString instead.

CODE

DateTimePicker1.Value.AddDays(7).ToShortDateString.ToUpper




the shortdatestring returns dates in numeric value like mm/dd/yy. I'm still stumped!
User is offlineProfile CardPM

Go to the top of the page

jayman9
post 1 Jul, 2008 - 09:34 AM
Post #4


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,241



Thanked 21 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


It would be helpful, in the future, if you include an example of what you want, in addition to the format.

Is this what you are looking for?
JAN 01 2008
or this
01 01 2008
User is offlineProfile CardPM

Go to the top of the page

AdamSpeight2008
post 1 Jul, 2008 - 09:44 AM
Post #5


D.I.C Regular

Group Icon
Joined: 29 May, 2008
Posts: 476



Thanked 31 times

Dream Kudos: 1850
My Contributions


QUOTE
CODE

DateTimePicker1.Value.AddDays(7).ToShortDateString.ToUpper


Try this.
CODE

TextBox1.Text = Format(DateTimePicker1.Value.AddDays(7).tostring, "MMM dd yyyy")
User is online!Profile CardPM

Go to the top of the page

hoehn_sj
post 1 Jul, 2008 - 10:50 AM
Post #6


New D.I.C Head

*
Joined: 9 Jun, 2008
Posts: 5


My Contributions


QUOTE(jayman9 @ 1 Jul, 2008 - 09:34 AM) *

It would be helpful, in the future, if you include an example of what you want, in addition to the format.

Is this what you are looking for?
JAN 01 2008
or this
01 01 2008



Jayman - sorry about no example and the confusion. I'm looking to have it look like:

MAY 22 2008

Thanks!
User is offlineProfile CardPM

Go to the top of the page

hoehn_sj
post 1 Jul, 2008 - 11:21 AM
Post #7


New D.I.C Head

*
Joined: 9 Jun, 2008
Posts: 5


My Contributions


QUOTE(AdamSpeight2008 @ 1 Jul, 2008 - 09:44 AM) *

QUOTE
CODE

DateTimePicker1.Value.AddDays(7).ToShortDateString.ToUpper


Try this.
CODE

TextBox1.Text = Format(DateTimePicker1.Value.AddDays(7).tostring, "MMM dd yyyy")




I tried the code you suggested but the return always is "MMM DD YYYY". I think that this is my fault due to not giving a good example of what I need. I need the date to be displayed like: MAY 22 2008.

Thanks for your help!
User is offlineProfile CardPM

Go to the top of the page

AdamSpeight2008
post 1 Jul, 2008 - 01:51 PM
Post #8


D.I.C Regular

Group Icon
Joined: 29 May, 2008
Posts: 476



Thanked 31 times

Dream Kudos: 1850
My Contributions


The error was mine blush.gif , remove the .ToString portion.

CODE

TextBox1.Text = Format(DateTimePicker1.Value.AddDays(7), "MMM dd yyyy")


or use the extended method
CODE

TextBox1.Text = DateTimePicker1.Value.AddDays(7).ToString("MMM dd yyyy")


This post has been edited by AdamSpeight2008: 1 Jul, 2008 - 02:14 PM
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/21/08 02:13PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month