date asp - to sql database

Posted on 2012-09-20
Last Modified: 2012-09-21
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

Question by:fedkris
    LVL 28

    Expert Comment

    by:Bill Bach
    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.
    LVL 52

    Expert Comment

    by:Scott Fell, EE MVE
    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

    Author Comment

    if i use date, he encodes 1900-01-01 00:00:00.000 in the table...
    LVL 32

    Accepted Solution

    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")

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Suggested Solutions

    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…
    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    737 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

    22 Experts available now in Live!

    Get 1:1 Help Now