Updating a datetime field with just the time input

Updating from a form:
(FP2003/SQL 2K SP3)

Have tried this many ways:

update SVC00200 set srvstat=::Status_set::,
Arrivdte='::ArrivedDate::',
ArrivTme=''1900-01-01'+' '+::ArriveTime::',
CompDte='::CompDate::',
CompTme='::CompTime::'
where callnbr='::Callnbr::'

update SVC00200 set srvstat=::Status_set::,
Arrivdte='::ArrivedDate::',
ArrivTme='::ArriveTime::',
CompDte='::CompDate::',
CompTme='::CompTime::'
where callnbr='::Callnbr::'

update SVC00200 set srvstat=::Status_set::,
Arrivdte='::ArrivedDate::',
ArrivTme=::ArriveTime::,
CompDte='::CompDate::',
CompTme='::CompTime::'
where callnbr='::Callnbr::'

ArrivDte and ArrivTme are datetime fields in SQL Server. This is for a website doing remote updates to an application database so I cannot change the field types. Don't ask me why they keep the date in one field and the time in another. Anyway, I can update the date just fine, but get various errors updateing the time from a form:

Syntax error converting datetime from character string
You should provide default values for all form fields that are used in the query.
Or some other various syntax errors.

Depending on how I've got the above code written. The default for both fields is 1900-01-01 00:00:00.000.
And when the fields are updated via the 'heavy' app the ArrivDte changes to 2004-11-11 00:00:00.000 and the ArrivTme changes to 1900-01-01 15:36:00.000.

A straight update statement works fine:

update svc00200
set arrivtme='3:00 PM'
where callnbr='0000031083'

and updates the arrivtme to 1900-01-01 15:00:00.000

The form code is:
<form method="POST" action="callupdated_new.asp">
<p>Call Number:<br>
<input type="text" name="callnbr" size="20" value="<%=request("CALLNBR")%>"></p>
<table border="0" width="41%" id="table1" style="border-collapse: collapse">
<tr>
<td colspan="3" bgcolor="#7288AC">
<p align="center"><b>Date/Time</b></td>
</tr>
<tr>
<td width="102">Arrived:</td>
<td>
<input type="text" name="Arriveddate" size="13" value="1900-01-01"></td>
<td>
<input type="text" name="ArrivedTime" size="11" value="00:00:00"></td>
</tr>
<tr>
<td width="102">Completed:</td>
<td>
<input type="text" name="Compdate" size="13" value="1900-01-01"></td>
<td>
<input type="text" name="CompTime" size="11" value="00:00:00"></td>
</tr>
</table>
<p>New Status:<br>
<font size="2">
<select size="1" name="Status_Set">
<option value="'10E'">Entered</option>
<option value="'15C'">Credit Hold</option>
<option value="'20N'">Notified</option>
<option value="'21A'">Acknowledged</option>
<option value="'30B'">Back Ordered</option>
<option value="'32P'">On P/O</option>
<option value="'45I'">In Transit</option>
<option value="'50D'">Dispatched</option>
<option value="'60A'">Arrived</option>
<option value="'65B'">Parts Arrived</option>
<option value="'70C'">Completed</option>
<option value="'00C'">Canceled</option>
</select></font></p>
<p><input type="submit" value="Update" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>


Any help is appreciated.
smoothriversAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

smoothriversAuthor Commented:
<%            
Dim mySQL
mySQL= "WHERE ArrivedTime = '" & Request.Form("ArrivedTime") & "'"
Response.write mySQL
Response.end
%>

does return 2:00 PM
0
hhammashCommented:
Hi,

Go into the database in the server
Open the table
go to the time field and put the format
hh:nn:ss  in the format

So when it is submitted by the form as 13:05:22 it will go to the database


hhammash
0
hhammashCommented:
Try this too,

See what I did to the form and the code after the form.  I modified your form and your code:


<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<title>Call Number</title>
</head>

<body>


<form method="POST" action="TimeFormat.asp">
<p>Call Number:<br>
<input type="text" name="callnbr" size="20" value="<%=request("CALLNBR")%>"></p>
<table border="0" width="41%" id="table1" style="border-collapse: collapse">
<tr>
<td colspan="3" bgcolor="#7288AC">
<p align="center"><b>Date/Time</b></td>
</tr>
<tr>
<td width="102">Arrived:</td>
<td>
<input type="text" name="Arriveddate" size="13" value="1900-01-01"></td>
<td>
<input type="text" name="T1" size="3" value="00">:<input type="text" name="T2" size="3" value="00">:<input type="text" name="T3" size="3" value="00"></td>
</tr>
<tr>
<td width="102">Completed:</td>
<td>
<input type="text" name="Compdate" size="13" value="1900-01-01"></td>
<td>
<input type="text" name="CompTime" size="11" value="00:00:00"></td>
</tr>
</table>
<p>New Status:<br>
<font size="2">
<select size="1" name="Status_Set">
<option value="'10E'">Entered</option>
<option value="'15C'">Credit Hold</option>
<option value="'20N'">Notified</option>
<option value="'21A'">Acknowledged</option>
<option value="'30B'">Back Ordered</option>
<option value="'32P'">On P/O</option>
<option value="'45I'">In Transit</option>
<option value="'50D'">Dispatched</option>
<option value="'60A'">Arrived</option>
<option value="'65B'">Parts Arrived</option>
<option value="'70C'">Completed</option>
<option value="'00C'">Canceled</option>
</select></font></p>
<p><input type="submit" value="Update" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
<%          
Dim mySQL
MyT1=request.form("T1")
MyT2=request.form("T2")
MyT3=request.form("T3")
MyTime=MyT1&":"&MyT2&":"&MyT3
mySQL= "WHERE ArrivedTime =" & MyTime
Response.write mySQL
Response.end
%>

</body>

</html>


hhammash
0
hhammashCommented:
This is for the format of AM and PM

When you did your SQL it is picking up the PM from your PC,  when I tried it on my PC I got 24 Format.  So you have to force it in the entry:


<form method="POST" action="TimeFormat.asp">
<p>Call Number:<br>
<input type="text" name="callnbr" size="20" value="<%=request("CALLNBR")%>"></p>
<table border="0" width="41%" id="table1" style="border-collapse: collapse">
<tr>
<td colspan="3" bgcolor="#7288AC">
<p align="center"><b>Date/Time</b></td>
</tr>
<tr>
<td width="102">Arrived:</td>
<td>
<input type="text" name="Arriveddate" size="13" value="1900-01-01"></td>
<td>
<input type="text" name="T1" size="3" value="00">:<input type="text" name="T2" size="3" value="00"><select size="1" name="T3">
<option>AM</option>
<option>PM</option>
</select></td>
</tr>
<tr>
<td width="102">Completed:</td>
<td>
<input type="text" name="Compdate" size="13" value="1900-01-01"></td>
<td>
<input type="text" name="CompTime" size="11" value="00:00:00"></td>
</tr>
</table>
<p>New Status:<br>
<font size="2">
<select size="1" name="Status_Set">
<option value="'10E'">Entered</option>
<option value="'15C'">Credit Hold</option>
<option value="'20N'">Notified</option>
<option value="'21A'">Acknowledged</option>
<option value="'30B'">Back Ordered</option>
<option value="'32P'">On P/O</option>
<option value="'45I'">In Transit</option>
<option value="'50D'">Dispatched</option>
<option value="'60A'">Arrived</option>
<option value="'65B'">Parts Arrived</option>
<option value="'70C'">Completed</option>
<option value="'00C'">Canceled</option>
</select></font></p>
<p><input type="submit" value="Update" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
<%          
Dim mySQL
MyT1=request.form("T1")
MyT2=request.form("T2")
MyT3=request.form("T3")
MyTime=MyT1&":"&MyT2&" "&MyT3
mySQL= "WHERE ArrivedTime =" & MyTime
Response.write mySQL
Response.end
%>


hhammash
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hhammashCommented:
When you process the form and send the value to the database use the value of mySQL.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.