Results 1 to 3 of 3

Thread: SOLVED: Converting string to datetime in SQL Server

  1. #1

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    Angry SOLVED: Converting string to datetime in SQL Server

    I try to do this:
    Code:
    rs.open "INSERT INTO tblY (dt) VALUES(CONVERT(DateTime, '190504072400'))", cn, and so on
    However, this won't work. Also trying to insert the same, but then formatted ("19-05-04 07:24:00 ") in the same query won't work. When I use GETDATE() (an sql server function), the date is inserted in the format I've set in red. Why can't I do that manually?

    Anyone? Thanx...
    Last edited by JMvVliet; Jun 21st, 2004 at 01:31 AM.

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611
    Try this:
    VB Code:
    1. rs.open "INSERT INTO tblY (dt) VALUES('2004-05-19 07:24:00'))", cn, and so on
    That should work, the conversion is done automatically
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  3. #3

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310
    That works, thanx

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