Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    27

    Unanswered: Insert date into access database

    I want to enter today's date when an application form is approved/rejected. I am setting this in a hidden textbox in my form.
    Code:
     <tr>
     <td><input type="hidden" name="hdnDate" value="<%response.write(FormatDateTime(date(), vbLongDate))%>"></td>
     </tr>
    when the send this information to the database, I get the following error:
    Type mismatch: 'FormatDateTime'

    Here is the relevant code that I use when updating to the database:
    Dim date, today
    date = request.form("hdnDate")
    today = FormatDateTime(date, vbLongDate)

    sql = "UPDATE MEMBER SET APP_STATUS = '" & varAccess & "', NEW_APPLICATION = '" & varNewApp & "', TODAYS_DATE = '" & today & "', COMMENTS = '" & comm & "' WHERE MEMBER_ID = " & varMemberID & ""

    the data type of the field in the database is Date/Time.

    Please help.........

  2. #2
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191
    You make a point of passing the date.... why? just use the system variable instead. If you MUST pass the date for some reason, you need to convert it before putting it into an SQL statement.

    Personally, I would NOT include the two lines at the top of your code that set "date" and "today"... and just do the following...

    From your SQL code....

    Instead of: ......., TODAYS_DATE = '" & today & "',

    try: TODAYS_DATE = #" & date & "#, ...etc...

    this will pass the date as a date literal instead of a string.

    Tim
    Tim

  3. #3
    Join Date
    Dec 2003
    Posts
    454

    Re: Insert date into access database

    Why did you post two questions with the same contents?

    http://www.dbforums.com/t984716.html

    Originally posted by lklegend
    I want to enter today's date when an application form is approved/rejected. I am setting this in a hidden textbox in my form.
    Code:
     <tr>
     <td><input type="hidden" name="hdnDate" value="<%response.write(FormatDateTime(date(), vbLongDate))%>"></td>
     </tr>
    when the send this information to the database, I get the following error:
    Type mismatch: 'FormatDateTime'

    Here is the relevant code that I use when updating to the database:
    Dim date, today
    date = request.form("hdnDate")
    today = FormatDateTime(date, vbLongDate)

    sql = "UPDATE MEMBER SET APP_STATUS = '" & varAccess & "', NEW_APPLICATION = '" & varNewApp & "', TODAYS_DATE = '" & today & "', COMMENTS = '" & comm & "' WHERE MEMBER_ID = " & varMemberID & ""

    the data type of the field in the database is Date/Time.

    Please help.........

  4. #4
    Join Date
    Jan 2004
    Posts
    27

    Re: Insert date into access database

    Thanks everyone. I solved the problem.

Posting Permissions

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