Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Date() and Now() for MSSQL

Posted on 2006-06-14
4
Medium Priority
?
1,610 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 total points
ID: 16907837
otherwise if you want the date and time from the sql server, use "getdate()".
0
 
LVL 96

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

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 informatio…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

604 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