Need help with date format

  • Thread starter Thread starter Phien-An Nguyen
  • Start date Start date
P

Phien-An Nguyen

Hello,

I have a TextBox1 binds to dateEnterred as datetime. My system date format
is m/d/yy. When I gave the value as string, "04/18/2008" to the
TextBox1.Text, it changed to "41/8/08".

Without changing the Date Format on the system and maintaining the datetime
datatype for dateEntered, how can I make the TextBox1.Text to bind value
"04/18/2008" instead of "41/8/08".


Thank you,

Phien-An
 
try the .ToString method of datetime type:
datetime.ToString(format as string)

in case, datetime.ToString("MM/dd/YYYY")


Thiago
 
Hello,

I have a TextBox1 binds to dateEnterred as datetime. My system date format
is m/d/yy. When I gave the value as string, "04/18/2008" to the
TextBox1.Text, it changed to "41/8/08".

Without changing the Date Format on the system and maintaining the datetime
datatype for dateEntered, how can I make the TextBox1.Text to bind value
"04/18/2008" instead of "41/8/08".

Thank you,

Phien-An

Hi,
DateString can provide you date omitted with hyphens "-", then you can
easily replace hyphens to slashes that matches your visiual desire.
So, place textbox named "textbox1" then here is your solution:

TextBox1.Text = DateString.ToString
TextBox1.Text = TextBox1.Text.Replace("-", "/")

Hope this helps,

Onur Güzel
 
Don't forget that there is a difference between lowercase m and uppercase M
on the date/time format. Looks like you had it using Minutes instead of
Months.
 
Mark,

In my idea you hit this one,

Cor

Mark said:
Don't forget that there is a difference between lowercase m and uppercase
M on the date/time format. Looks like you had it using Minutes instead of
Months.
 
Back
Top