Results 1 to 5 of 5

Thread: Format a date in VB.net

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Format a date in VB.net

    I have a calendar control which populates a textbox.
    The date is in American format e.g "MM/DD/YYYY"
    I need to convert this into "YYYY-MM-DD" so that I can insert it into a MYSQL database.

    ANy ideas ?

    I hate dates


    TIA

    Parksie

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try this :

    VB Code:
    1. TextBox1.Text() = Format(Now.Today(), "MM,dd,yyyy")

  3. #3

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    You never seem to let me down Pirate.

    Cheers :-)

    Parksie

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Just my 2 cents worth but I picked this up from the net last week - you can specify the date formatting after the ".tostring" call for another time...

    Now.ToString("dd/mm/yyyy")

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question

    Couldn't you just assign the date value to the OleDbCommand object and let ADO.NET do the rest for you?
    VB Code:
    1. .Parameters.Add(New OleDb.OleDbParameter("@MyBirthdateField", OleDbType.Date))
    ~Peter


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width