Results 1 to 4 of 4

Thread: Converting date from textbox to DateTime

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Posts
    149

    Converting date from textbox to DateTime

    I have a date in a textbox that came from a popup Calendar control. Now I would like to take the date i returned to this textbox and update it to an SQL Server, but the problem is that the value have to be DateTime and not text.

    Can anyone tell me how to do this please.

    Thanks.

  2. #2
    Addicted Member
    Join Date
    Aug 2004
    Location
    Cape Town, South Africa
    Posts
    149

    Re: Converting date from textbox to DateTime

    VB Code:
    1. Dim dteDate as date
    2.  
    3. dteDate = ctype(textbox1.text, date)

    If you want to check if it is a date first, you can use the IsDate() function.

  3. #3
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Re: Converting date from textbox to DateTime

    System.Convert

    or construct a new datetime from the string date time
    Magiaus

    If I helped give me some points.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Posts
    149

    Re: Converting date from textbox to DateTime

    Thanks to the both of you for the replies. I tried both already, but it was really my own stupidity that prevented it from working. The field I was converting was disabled and so the value being converted was '' and thus wouldnt work.

    Thanks again guys.

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