Inserting Time field into Access Database

Results 1 to 2 of 2

Thread: Inserting Time field into Access Database

  1. #1
    Travis Tubbs Guest

    Default Inserting Time field into Access Database

    I have been trying to take a form field from the web filled in with a time and insert it <BR><BR>into an Access database. This is a snippet of my original coding:<BR><BR>----------<BR><BR>&#060;%<BR>TimeInHour = request.form("TimeInHour")<BR>TimeInMin = request.form("TimeInMin")<BR>TimeInNom = request.form("TimeInNom")<BR><BR>TimeIn = TimeInHour & ":" & TimeInMin & " " & TimeInNom<BR><BR>set conn = server.createobject("adodb.connection")<BR>conn.op en "timekeeper"<BR>SQLstmt = "INSERT INTO AsstTime (TimeIn) VALUES (&#039" & TimeIn & "&#039)"<BR><BR>conn.close<BR>set conn=nothing<BR>%&#062;<BR><BR>----------<BR><BR>For Example:<BR>TimeInHour = 12<BR>TimeInMin = 30<BR>TimeInNom = PM<BR><BR>TimeIn = 12:30 PM<BR><BR>I always get the following error:<BR>Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)<BR>[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.<BR><BR>I have tried several methods to get the database to recognize the string I&#039m entering is <BR><BR>Time. Methods I have tried included:<BR><BR>TimeIn = FormatDateTime(TimeIn, 3) --and-- TimeIn = CDate(TimeIn)<BR><BR>Both of those methods did not seem to work as well.<BR><BR>Could someone please tell me what I&#039m doing wrong and how I can fix this so that the time is <BR><BR>added to the database with ease?<BR><BR>I am running IIS5 on Windows 2000 Professional.<BR><BR>- Travis Tubbs<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Inserting Time field into Access Database

    One thing I am seeing is that you are passing this value to the Access database as a string value (you are using single quotes). Is it set up as a text field in your database?

Posting Permissions

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