Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting a date to go into an access database

Status
Not open for further replies.

gmagerr

Technical User
Aug 11, 2001
323
US
Hello all, i know this is probably simple, but i'm burnt out. i have a field in my access database that's a Date/Time format. i'm trying to insert a new record from an asp form, but i keep getting the type mismatch error. How do i format the data coming from the form to be a date format? Thanks.
 
I always convert it into a format like 26-Jan-2002 to ensure there are no confusions between month and day (some countries write it in month/day/year format, or year/month/day).

Then just remember to wrap it in hashs (#) for insertion into Access.

Check out the DatePart function in VBScript. codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
<insert witticism here>
 
Ok, i'm not sure what you mean by the # around the date. the line i want to insert is something like this

reEmployee(&quot;Birthdate&quot;) = Request.Form(&quot;Birthdate&quot;)

so how would i format the request.form(&quot;Birthdate&quot;) part to go into the database as a date?
Thanks for the reply.
 
Ahh, you're using the old .update method.
Let's see - this should give you thew idea.
<%@enablesessionstate=&quot;false&quot;%>
<html>
<head>
<title>QS to Date Test</title>
</head>
<body>
<script runat=&quot;server&quot; language=&quot;vbscript&quot;>
if len(Request.QueryString(&quot;testdate&quot;)) > 0 then
dim dt_Date
dim str_Months(11)
str_Months(0) = &quot;Jan&quot;
str_Months(1) = &quot;Feb&quot;
str_Months(2) = &quot;Mar&quot;
str_Months(3) = &quot;Apr&quot;
str_Months(4) = &quot;May&quot;
str_Months(5) = &quot;Jun&quot;
str_Months(6) = &quot;Jul&quot;
str_Months(7) = &quot;Aug&quot;
str_Months(8) = &quot;Sep&quot;
str_Months(9) = &quot;Oct&quot;
str_Months(10) = &quot;Nov&quot;
str_Months(11) = &quot;Dec&quot;
dt_Date = Request.QueryString(&quot;testdate&quot;)
Response.Write datepart(&quot;d&quot;, dt_Date) & &quot;-&quot; & str_Months(datepart(&quot;m&quot;, dt_Date)-1) & &quot;-&quot; & datepart(&quot;yyyy&quot;, dt_Date)
end if
</script>
</body>
</html>
(there's also the day, month and year f'ns in vbscript) codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
<insert witticism here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top