custom date formatting

B

Ben

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



--
 
K

kimiraikkonen

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
 
H

Harry

Ben said:
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
 
C

Cor Ligthert[MVP]

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
 
K

kimiraikkonen

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
 
C

Cor Ligthert[MVP]

Onur,

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

:)

Cor

"kimiraikkonen" <[email protected]> schreef in bericht
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top