Solved

Date() and Now() for MSSQL

Posted on 2006-06-14
4
1,599 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
two submit buttons one form 15 73
API not working 33 54
Need help editing script 3 65
CDO.Message not able to send attachement 5 10
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…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

929 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now