Solved

Date() and Now() for MSSQL

Posted on 2006-06-14
4
1,601 Views
Last Modified: 2006-11-18
I am getting an error on my date and now functions when trying to insert into the MSSQL database:

      strSQLTST = ("Insert into Transactions "_
      &"(buyerID, "_
      &"sellerID, "_
      &"Type, "_
      &"[date], "_
      &"[dateTime], "_
      &"Location, "_
      &"status, "_
      &"amountW) "_
      &"VALUES "_
      
      &"("&      User&      ","_
      &""&      -1&            ","_
      &""&      3&            ","_
      &"date()," _
      &"Now()," _
      &"'"& Home &"'," _
      &"'Complete'," _
      &""&      Deduct&      ")")

What do I use for MSSQL?  This was originally for Access =)  Thanks!
0
Comment
Question by:JuniorBee
  • 2
4 Comments
 
LVL 22

Expert Comment

by:WMIF
ID: 16907824
use the vb functions and put quotes around them.

strSQLTST = ("Insert into Transactions "_
     &"(buyerID, "_
     &"sellerID, "_
     &"Type, "_
     &"[date], "_
     &"[dateTime], "_
     &"Location, "_
     &"status, "_
     &"amountW) "_
     &"VALUES "_
     
     &"("&     User&     ","_
     &""&     -1&          ","_
     &""&     3&          ",'"_
     &date() & "','" _
     &Now() & "'," _
     &"'"& Home &"'," _
     &"'Complete'," _
     &""&     Deduct&     ")")
0
 
LVL 22

Accepted Solution

by:
WMIF earned 500 total points
ID: 16907837
otherwise if you want the date and time from the sql server, use "getdate()".
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 16907909
Why are you using TWO date fields - it looks like Date and DateTime?  A single field can cover both.
0
 

Author Comment

by:JuniorBee
ID: 16907917
I forgot why I was using 2.  :/
I know it was for a good reason.  (laughs)
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
EOF BOF error classic asp 8 48
Copy only dates 3 89
Microsoft SQL ADO Conn Issue 6 48
Connecting to multiple databases to create a Dashboard 5 26
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question