Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 datetime on an insert

Author  Topic 

tgreen
Starting Member

3 Posts

Posted - 2002-11-04 : 08:32:06
I have a table called taskorders where individuals enter data on a web page that actually runs an insert statement to produce task orders for a labor force. I have come to find out that there are some that are "fudging" the request dates sometimes and am trying to figure out how I can have the date and time inserted automatically during when the sql is executed.

I have seen a function called Now but I do not know how to format that part of it so that it would automatically insert.



the insert is as follows:

<%
sql = "INSERT INTO dbo.Tasks (requestdate, requiredate, prepby, AD700, room_number, phone_number, "
sql = sql & " status, requestor_name, Agency, Division, requestor_phone, requestor_room, Requestor_bldg, "
sql = sql & " request, request1, service_hours, required_labor ) Values ("
sql = sql & "'" & Request("txtrequestdate") & "',"
sql = sql & "'" & Request("txtrequiredate")& "',"
sql = sql & "'" & Request("txtprepby")& "',"
sql = sql & "'" & Request("txtad700")& "',"
sql = sql & "'" & Request("txtroom_number")& "',"
sql = sql & "'" & Request("txtphone_number")& "',"
sql = sql & "'" & Request("txtStatus")& "',"
sql = sql & "'" & Request("txtrequestor_name")& "',"
sql = sql & "'" & Request("txtagency")& "',"
sql = sql & "'" & Request("txtdivision")& "',"
sql = sql & "'" & Request("txtrequestor_phone")& "',"
sql = sql & "'" & Request("txtrequestor_room")& "',"
sql = sql & "'" & Request("txtrequestor_bldg")& "',"
sql = sql & "'" & Request("txtrequest")& "',"
sql = sql & "'" & Request("txtrequest1")& "',"
sql = sql & "'" & Request("txtservice_hours")& "',"
sql = sql & "'" & Request("txtrequired_labor")& "')"

%>

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2002-11-04 : 08:37:31
getdate() is what you need


you may need to used the convert() function to format the date value to a format (US, UK/European, Swedish, etc) useful to you....


there are many example here of both...GETDATE and CONVERT

Go to Top of Page
   

- Advertisement -