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

Updating date-field in database with ASP

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I've got a database that users are supposed to edit online. One of the columns is formated as date/time. When I try to update it using:

<%
MyTempDate=&quot;07/25/2001&quot; (actually read from a passed string)
Conn.Execute(&quot;Update MyTable Set UserDateField=&quot; & MyTempDate)
%>

or

<%
Conn.Execute(&quot;Update MyTable Set UserDateField='&quot; & MyTempDate&quot;'&quot;)
%>

I get error messages. I assume that the problem is to format it somehow, but I don't know how. The MyTempDate is gathered from a query from the table, so it should be in its correct format.

Can anybody help me? I'm freaking out cause I've got a deadline comming up.

Thx
 
If u are in sql u must palce the date between quotes (ie '07/25/2001') or if u are using acess place # instead quotes (ie #07/25/2001#)
Also u need an where condition to make just one update not manny
try this

Code:
MyTempDate=&quot;07/25/2001&quot;
Conn.Execute(&quot;Update MyTable Set UserDateField='&quot; & MyTempDate & &quot;' where UserDateField='&quot;&oldvalue&&quot;'&quot;)
________
George, M
 
If you are using Oracle, consider using the TO_DATE SQL function to convert your string to a date.

I assume other databases would have a similar function but I could be wrong.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top