If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Insert date into access database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-23-04, 09:59
lklegend lklegend is offline
Registered User
 
Join Date: Jan 2004
Posts: 27
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.........
Reply With Quote
  #2 (permalink)  
Old 02-23-04, 15:27
MrWizard MrWizard is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 02-23-04, 16:35
gyuan gyuan is offline
Registered User
 
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

Quote:
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.........
Reply With Quote
  #4 (permalink)  
Old 02-24-04, 05:09
lklegend lklegend is offline
Registered User
 
Join Date: Jan 2004
Posts: 27
Re: Insert date into access database

Thanks everyone. I solved the problem.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On