Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: now() syntax


Message #1 by "Jake C" <jakeone@b...> on Mon, 20 Nov 2000 13:11:04 -0000
hi

there is an error in your code
if u want to use now() you need to specify it outside the query
if u are using it inside the query, it has to be getdate not now

you have 2 solutions

(1)  if you want the date of IIS server

sqlString =3D "INSERT INTO Orders (" &_
  "order_ID," &_
  "order_userID," &_
  "order_date," &_
  ") SELECT " &_
  "cart_ID," &_
  "cart_userID," &_
  "' & now() & '," &_
  "FROM Cart"

(2) if you want the SQL Server date

sqlString =3D "INSERT INTO Orders (" &_
  "order_ID," &_
  "order_userID," &_
  "order_date," &_
  ") SELECT " &_
  "cart_ID," &_
  "cart_userID," &_
  "getdate," &_
  "FROM Cart"

jigs



  ----- Original Message -----
  From: Jake C
  To: sql language
  Sent: Monday, November 20, 2000 6:41 PM
  Subject: [sql_language] now() syntax


  Can anyone tell me what I'm doing wrong with the following?  I get an
  error message, "'now' is not a recognised function" or - after 
tinkering
  with the syntax - now() is interpreted as a string and 'now()' is 
inserted
  into my table.

  sqlString =3D "INSERT INTO Orders (" &_
    "order_ID," &_
    "order_userID," &_
    "order_date," &_
    ") SELECT " &_
    "cart_ID," &_
    "cart_userID," &_
    "'now()'," &_
    "FROM Cart"

  Con.Execute sqlString

  Cheers.


  Return to Index