Updating a date field

Results 1 to 2 of 2

Thread: Updating a date field

  1. #1
    Join Date
    Dec 1969

    Default Updating a date field

    FUSTRATION<BR><BR>Just how do you update a recordset with a date field EG.<BR><BR>strSQL = "SELECT * FROM authorised WHERE authorised_id = " &varID <BR><BR>Set objRS = Server.CreateObject("ADODB.RecordSet")<BR>&#039;ob jRS.Open strSQL, objConn<BR><BR>objRS.Open strSQL, objConn, 0, 2 <BR><BR><BR>&#039; GET ITEMS FROM FORM TO INPUT INTO CUSTOMER DATABASE<BR><BR>objRS("date") = request.form("date")<BR><BR>&#039;objRS("blocks") = request.form("blocks")<BR>&#039;objRS("paid") = request.form("paid")<BR>&#039;objRS("status") = request.form("status")<BR>objRS.update<BR><BR> objRS.Close<BR> Set objRS = Nothing<BR> objConn.Close<BR> Set objConn = Nothing<BR><BR>ALWAYS RETURNS AN ERROR even if wrapped in [] or ##<BR><BR>PLEASE HELP ITS DRIVING ME MAD and i can&#039;t find it in and FAQ<BR>

  2. #2
    Join Date
    Dec 1969

    Default objRS(whatever) = CDATE(value)

    objRS("date") = CDATE( request.form("date") )<BR><BR>Oy...but you have a field named "date". Not sure if you can make that work. Never tried.<BR><BR>But this is a yucky way to do it, in any case.<BR><BR>Much better to do:<BR><BR>&#060;%<BR>newdate = Request.Form("date")<BR>If IsDate(newdate) Then<BR> newdate = CDate(newdate)<BR>Else<BR> Response.Write "Invalid date, try again"<BR> Response.End<BR>End If<BR><BR>strSQL = "UPDATE authorised SET [date]=#" & CDate & "# " _<BR> & " WHERE authorised_id = " & varID <BR>objConn.Execute strSQL<BR>objConn.Close &#039; done...nothing more<BR>%&#062;<BR><BR>That assumes Access DB. Change # to &#039; if not.<BR><BR>

Posting Permissions

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