custom date formatting

  • Thread starter Thread starter Ben
  • Start date Start date
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



--
 
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
 
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
 
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
 
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
 
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
 
Back
Top