[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • Last Modified:

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

0
fedkris
Asked:
fedkris
1 Solution
 
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 MVEDeveloperCommented:
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
 
Big MontySenior 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
 
fedkrisAuthor Commented:
thx
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now