Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Posts
    2

    Unanswered: how to insert current date in sql server

    hi all

    am new here
    can any one plz help me my problem is

    am trying to insert current date using asp aand sql server

    when i insert date i look to database and found 1/1/1900 i search the net but nothing work

    column data type is datetime

    plz help me

  2. #2
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191
    Option 1: UPDATE tablename SET datefieldname =' & date() & "'"
    Option 2: INSERT INTO tablename (datefieldname) VALUES ('" & date() & "')
    Tim

  3. #3
    Join Date
    Dec 2004
    Posts
    2
    thanks for help

    but when i use this error occured
    The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

    i try this but another error occuer
    getdate="select convert(datetime, getdate()) as dd"
    set rs=server.createobject("adodb.recordset")
    call connect
    rs.open getdate,cn
    date1=rs.fields("dd")
    response.write date1

    SqlInsert ="insert into inbox"
    SqlInsert = SqlInsert & "(name,country,email,subject,massege,id,date1,chec ked)"
    SqlInsert = SqlInsert & "values('"& name &"','" & country & "','" & email & "','" & subject & "','" & massege & "'," & id & ",'" & rs.fields("dd") & "','" & 1 & "')"

    the error will be
    Syntax error converting datetime from character string.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •