date asp - to sql database

hello, i want to add a date (in asp) into an sqltable

my aspcode:

q_date = year(date)&"-"&month(date)&"-"&day(date)

=) result on page:  2012-9-20

when i encode it in sql (field = UNSUBSCRIBED, format     datetime

in my table it becomes: 1905-06-07 00:00:00.000

i want today's date, how can i resolve this?

q_lng =Request("lng")
q_date = year(date)&"-"&month(date)&"-"&day(date)


set cn=server.CreateObject("ADODB.Connection")
cn.Open Application("connstring")	
	strsql= "UPDATE [table].[su].[CONT] SET [UNSUBSCRIBED] = "&q_date&" WHERE IDCONTACT=" & request("idcontact") 	
	set rst2=server.CreateObject("ADODB.Recordset")
  rst2.Open strsql, cn 	

Open in new window

fedkrisAsked:
Who is Participating?
 
Big MontyConnect With a Mentor Senior Web Developer / CEO of ExchangeTree.org Commented:
if you want to just get the current date and store it, do it in your query using getdate()

strsql= "UPDATE [table].[su].[CONT] SET [UNSUBSCRIBED] = getdate() WHERE IDCONTACT=" & request("idcontact")
0
 
Bill BachPresidentCommented:
You can try using the date-specific format, like this:
    {d '2012-09-20'}
Or, use a built-in function like CURDATE() instead of building the date in your app.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Just use date() or date



set cn=server.CreateObject("ADODB.Connection")
cn.Open Application("connstring")      
      strsql= "UPDATE [table].[su].[CONT] SET [UNSUBSCRIBED] = "&date&" WHERE IDCONTACT=" & request("idcontact")       
      set rst2=server.CreateObject("ADODB.Recordset")
  rst2.Open strsql, cn
0
 
fedkrisAuthor Commented:
if i use date, he encodes 1900-01-01 00:00:00.000 in the table...
0
 
fedkrisAuthor Commented:
thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.