Need help with date format

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phien-An Nguyen

    Need help with date format

    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

  • Thiago Macedo

    #2
    Re: Need help with date format

    try the .ToString method of datetime type:
    datetime.ToStri ng(format as string)

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


    Thiago

    Comment

    • Thiago Macedo

      #3
      Re: Need help with date format

      On 16 abr, 16:03, Thiago Macedo <thiago.ch...@g mail.comwrote:
      try the .ToString method of datetime type:
      datetime.ToStri ng(format as string)
      >
      in case, datetime.ToStri ng("MM/dd/YYYY")
      >
      Thiago
      I think this article will help you:

      Comment

      • kimiraikkonen

        #4
        Re: Need help with date format

        On Apr 16, 8:41 pm, "Phien-An Nguyen" <onok...@gmail. comwrote:
        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.ToSt ring
        TextBox1.Text = TextBox1.Text.R eplace("-", "/")

        Hope this helps,

        Onur Güzel

        Comment

        • Mark

          #5
          Re: Need help with date format

          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.


          "Phien-An Nguyen" <onokiyo@gmail. comwrote in message
          news:eIR$ek%23n IHA.3532@TK2MSF TNGP03.phx.gbl. ..
          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

          Comment

          • Cor Ligthert[MVP]

            #6
            Re: Need help with date format

            Mark,

            In my idea you hit this one,

            Cor

            "Mark" <tropicalzany@f use.netschreef in bericht
            news:eTQ%23BsBo IHA.3960@TK2MSF TNGP02.phx.gbl. ..
            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.
            >
            >
            "Phien-An Nguyen" <onokiyo@gmail. comwrote in message
            news:eIR$ek%23n IHA.3532@TK2MSF TNGP03.phx.gbl. ..
            >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.Tex t, 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
            >

            Comment

            Working...