Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to update a date field using Update statement

Status
Not open for further replies.

axslearnr

Technical User
Apr 1, 2004
78
US
Hi
I need to update a date field in a employee table using update statement. It doesnt update it. I dont even get any error in there. Please let me know.
Last_Login is date field. I want to put todays date in there


userName = session("Userid")
set RST=Server.CreateObject("adodb.recordset")
strSQL = "UPDATE employee SET [Last_Login]='"& Now() &"' WHERE UserName = '" & userName & "';"

RST.open strSQL, conn
 
you could use the SQL Now() function

Code:
strSQL = "UPDATE employee SET [Last_Login]= Now() WHERE UserName = '" & userName & "';"



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Hi
Thanks for ur reply. I tried that didn't updated the date field.

pls let me know
thank you
 
The code that ChrisHirst provided should have worked. The difference between your code and his was the removal of the quotes around the Now() function. Did you remove those and try it? Also, you might response.write out your value to the screen and then test it in Access (since that appears to be what you are using). For additional help, try FAQ333-4896.

------------------------------------------------------------------------------------------------------------------------
"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."
--Dou
 
if you're using an MS Access db then you'll need :

strSQL = "UPDATE employee SET [Last_Login]=#" & Now() & "# WHERE UserName = '" & userName & "'"


[thumbsup2]DreX
aKa - Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top