Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
| Search | Today's Posts | Mark Forums Read
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2005, 09:10 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: , , .
Posts: 198
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via MSN to itHighway
Default Sql Server DateTime field Vs ASP

Hello,

I am having problem with DateTime field in Sql Server db.

FieldName: LastActionBy
FieldType: DateTime

I want to Update Current Date and Time and using following query.

"Update LOGS SET LastActionBy = '"& NOW() &"' WHERE ID = 5"

The error I get is
"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value"

The above mentioned query was working fine. But now it is not.



I tried following queries as well, but getting same result.
"Update LOGS SET LastActionBy = "& NOW() &" WHERE ID = 5"
"Update LOGS SET LastActionBy = #"& NOW() &"# WHERE ID = 5"


Please help!!


Regards
Zeeshan Ahmed

 
Old August 15th, 2005, 05:41 PM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

If you are using SQL server, then use the following query:

"Update LOGS SET LastActionBy = getDate() WHERE ID = 5"



Om Prakash
 
Old August 16th, 2005, 02:38 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Alternatively, debug your SQL statement like this:

Response.Write("Sql is " & "Update LOGS SET LastActionBy = '"& NOW() &"' WHERE ID = 5")

Do you see anything odd? Is there a difference between regional settings of your web server and your database server?

I do agree with om_prakash that GetDate() is better as it gives you the date and time right where you want it: in the database...

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Nowhere Fast by Incubus (Track 2 from the album: Make Yourself) What's This?




Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Use DateTime Field kcsathish ASP.NET 2.0 Professional 0 July 15th, 2008 01:01 AM
ASP, Sql Server DateTime field itHighway Classic ASP Basics 1 August 14th, 2005 06:32 PM
SQL Server, field length of 20000 itHighway Classic ASP Databases 3 December 27th, 2004 01:16 AM
rownum field in sql server mateenmohd SQL Server 2000 2 June 12th, 2003 04:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.