By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,263 Members | 2,640 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,263 IT Pros & Developers. It's quick & easy.

custom date formatting

P: n/a
All -

I have VB2008. On the form I have a date picker and a text box.
I put would like to display a date format in the form of "MM-DD-YYYY" or
"MM-YYYY"
I am new to vb2008, can you show me how to do this?

Thank you,

Ben

--

Oct 9 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Oct 9, 11:03 pm, Ben <B...@discussions.microsoft.comwrote:
All -

I have VB2008. On the form I have a date picker and a text box.
I put would like to display a date format in the form of "MM-DD-YYYY" or
"MM-YYYY"
I am new to vb2008, can you show me how to do this?

Thank you,

Ben

--
Assuming you have a "DateTimePicker" control on your form, first
change DateTimePicker's "Format" property to "Custom" then set its
"CustomFormat" property to "mm-dd-yyyy" (without quotes, of course)
through properties window. Follow the same for "mm-yyyy" format.

Now you can show it in your textbox like that;
TextBox1.Text = DateTimePicker1.Text

Hope this helps,

Onur Güzel

Oct 9 '08 #2

P: n/a

"Ben" <Be*@discussions.microsoft.comwrote in message
news:ED**********************************@microsof t.com...
All -

I have VB2008. On the form I have a date picker and a text box.
I put would like to display a date format in the form of "MM-DD-YYYY" or
"MM-YYYY"
I am new to vb2008, can you show me how to do this?

Thank you,

Ben
Set the Format property and then set Custom Format to "MM-DD-YYYY" or
whatever
Oct 9 '08 #3

P: n/a
Ben,

You can custom a date to any format, some are predifined others not.

By instance with

String x = Now.ToString("MM-dd-yyyy")

Be aware that the month is with upper caption, as lower caption means
minutes.

Cor
"Ben" <Be*@discussions.microsoft.comschreef in bericht
news:ED**********************************@microsof t.com...
All -

I have VB2008. On the form I have a date picker and a text box.
I put would like to display a date format in the form of "MM-DD-YYYY" or
"MM-YYYY"
I am new to vb2008, can you show me how to do this?

Thank you,

Ben

--
Oct 10 '08 #4

P: n/a
On Oct 9, 11:27*pm, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Oct 9, 11:03 pm, Ben <B...@discussions.microsoft.comwrote:
All -
I have *VB2008. *On the form I have a date picker and a text box.
I put would like to display a date format in the form of "MM-DD-YYYY" or
"MM-YYYY"
I am new to vb2008, can you show me how to do this?
Thank you,
Ben
--

Assuming you have a "DateTimePicker" control on your form, first
change DateTimePicker's "Format" property to "Custom" then set its
"CustomFormat" property to "mm-dd-yyyy" (without quotes, of course)
through properties window. Follow the same for "mm-yyyy" format.

Now you can show it in your textbox like that;
TextBox1.Text = DateTimePicker1.Text

Hope this helps,

Onur Güzel
To make a correction for myself, you can use "MM-dd-yyyy" to get date
format as uppercase "MM" represents month value whereas lowercase "mm"
represents minutes. Same, you can use "MM-YYYY" as date.

And sure, you can use Short, Long formats which are presented
alreadyby DateTimePicker.

Thanks,

Onur Güzel
Oct 10 '08 #5

P: n/a
Onur,

I saw it, but did not know how to phrase it, therefore I made a new message.

:-)

Cor

"kimiraikkonen" <ki*************@gmail.comschreef in bericht
news:f2**********************************@8g2000hs e.googlegroups.com...
On Oct 9, 11:27 pm, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Oct 9, 11:03 pm, Ben <B...@discussions.microsoft.comwrote:
All -
I have VB2008. On the form I have a date picker and a text box.
I put would like to display a date format in the form of "MM-DD-YYYY" or
"MM-YYYY"
I am new to vb2008, can you show me how to do this?
Thank you,
Ben
--

Assuming you have a "DateTimePicker" control on your form, first
change DateTimePicker's "Format" property to "Custom" then set its
"CustomFormat" property to "mm-dd-yyyy" (without quotes, of course)
through properties window. Follow the same for "mm-yyyy" format.

Now you can show it in your textbox like that;
TextBox1.Text = DateTimePicker1.Text

Hope this helps,

Onur Güzel
To make a correction for myself, you can use "MM-dd-yyyy" to get date
format as uppercase "MM" represents month value whereas lowercase "mm"
represents minutes. Same, you can use "MM-YYYY" as date.

And sure, you can use Short, Long formats which are presented
alreadyby DateTimePicker.

Thanks,

Onur Güzel
Oct 10 '08 #6

P: n/a
Thank you all

Ben

--

"Ben" wrote:
All -

I have VB2008. On the form I have a date picker and a text box.
I put would like to display a date format in the form of "MM-DD-YYYY" or
"MM-YYYY"
I am new to vb2008, can you show me how to do this?

Thank you,

Ben

--
Oct 10 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.