Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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 November 25th, 2005, 03:33 PM
Authorized User
 
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to x_ray
Default Converting from character to smalldatetime

i have a problem in converting character input into datetime or smalldatetime input.the problem is i have an asp page with javascript that sends, in query,the time in characters to the database on SQL Server 2000, but this is causing an error:

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value...
although i used the convert function but it didn't work(same error),
so i cannot insert any row into database. What should i do? i need help badly on this one!:(

 
Old November 25th, 2005, 03:41 PM
Authorized User
 
Join Date: Sep 2005
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is the date a valid date, are you doing validation?
How are you passing the date in, can you give an example?
Look at the range below
datetime
Date and time data from January 1, 1753 through December 31, 9999

smalldatetime
Date and time data from January 1, 1900, through June 6, 2079



“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" -- http://sqlservercode.blogspot.com/
 
Old November 26th, 2005, 06:01 AM
Authorized User
 
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to x_ray
Default

ok, i am using the following in the javascript,
Code:
var cdate= new Date();//gets me the current date
.
.
.
var sql="Insert into tablex values ("+cdate+")";
if i use
var sql="Insert into tablex values ('"+cdate+"')";
i get the error of conversion of characters to date time,if i use the first one a get something about variables and constants,and rejects the day part ("Thu,Fri,...."). i will try some more validation and get back to you with the results, but hope you assist me meanwhile. 10x lot






Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax error converting datetime from character st vinod_yadav1919 SQL Server 2000 2 September 10th, 2010 10:11 AM
Converting to character from date string denver Access VBA 7 June 9th, 2006 07:30 AM
Converting an ASCII character to binary? skyraider Visual Basic 2005 Basics 0 May 7th, 2006 08:20 PM
Converting Unicode to Character RobinR Classic ASP Basics 4 August 6th, 2004 11:40 AM





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