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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inputing a date into a sql database

Status
Not open for further replies.

krappleby025

Programmer
Sep 6, 2001
347
NL
Hi all,

I have the following script

mysql = mysql & ", DOB = '#" & request.form("DOB") & "#'"

Which is supposed to put a date in the format mm/dd/yyyy into a mysql database

The database field is set to date, can anyone tell me what i am doing wrong, the above does not work it does not place the date in the field

veriations i have tried

DOB = '#" & request.form("DOB") & "#'
DOB = #'" & request.form("DOB") & "'#
DOB = #" & request.form("DOB") & "#

Non seem to work, can you help
ps the form field is entered as for example 06/23/1976

Thanks in advance
 
mysql = mysql & ", DOB = '" & cdate(request.form("DOB")) & "'"

No # for SQL database Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
thanks for the advice, however that has not worked either, i do not get an error, just does not add the record to the database

any other ideas

thanks
 
Can you post the whole code relating to this. Are all values being definitely passed etc, have you tried taking parts of the sql statement out and seeing if it works, trying doing a 'response.write sql' to make sure the sql statement is correct Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
ok the entire update code is

mysql = "UPDATE " & Memberstable & " SET "
mysql = mysql & " FirstName = '" & request.form("FirstName") & "'"
mysql = mysql & ", LastName = '" & request.form("LastName") & "'"
mysql = mysql & ", Email = '" & request.form("Email") & "'"
mysql = mysql & ", Password = '" & request.form("Password") & "'"
mysql = mysql & ", Address1 = '" & request.form("Address1") & "'"
if request.form(&quot;Address2&quot;) <> &quot;&quot; then
mysql = mysql & &quot;, Address2 = '&quot; & request.form(&quot;Address2&quot;) & &quot;'&quot;
End if
mysql = mysql & &quot;, Town = '&quot; & request.form(&quot;Town&quot;) & &quot;'&quot;
mysql = mysql & &quot;, Province = '&quot; & request.form(&quot;Province&quot;) & &quot;'&quot;
mysql = mysql & &quot;, Country = '&quot; & request.form(&quot;Country&quot;) & &quot;'&quot;
mysql = mysql & &quot;, PostalCode = '&quot; & request.form(&quot;PostalCode&quot;) & &quot;'&quot;
mysql = mysql & &quot;, DOB = '&quot; & cdate(request.form(&quot;DOB&quot;)) & &quot;'&quot;
if request.form(&quot;PaymentMethod&quot;) <> &quot;&quot; then
mysql = mysql & &quot;, PaymentMethod = '&quot; & request.form(&quot;PaymentMethod&quot;) & &quot;'&quot;
End if
if request.form(&quot;AccountDetails&quot;) <> &quot;&quot; then
mysql = mysql & &quot;, AccountDetails = '&quot; & request.form(&quot;AccountDetails&quot;) & &quot;'&quot;
End if
con.execute mysql

The rest of the code works fine, it is only the section for the date,

here is the settings for the mysql database

DOB date No 0000-00-00

of course the No column is Null

Thanks
 
Theres nothing in there to say which record to update! Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
You don't need to convert the parameter to a date using CDate() because you're concatenating it with a string which will convert it back into a string anyway, but possibly in a different format than what was entered. Try your query with the single quote delimiter, but without the CDate().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top