Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 December 22nd, 2009, 05:26 AM
Authorized User
 
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
Default he conversion of a char data type to a datetime data type resulted in an out-of-range

Hi there

I'm getting the following error:

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

This is the statement that's causing it:

SELECT p.productid, p.subcategoryid, p.productname, p.partnumber, p.rrp, p.cost, p.enddate, p.weight, p.tagline, LEFT(CAST(p.extrainformation as varchar(100)), 100) AS 'extrainformation', p.imagename, p.imagename_m, p.imagename2, p.imagename3, st.id, st.stock, p.onspecial, 1 As fIsSpecial, p.sequence As sequence FROM product p, tbl_stock st WHERE DATEDIFF(day, p.enddate, GETDATE()) < 0 AND p.deleted = 0 AND p.hide = 0 AND st.id = p.stock AND p.enddate = '31/12/2009' AND p.promotionid = '9' ORDER BY fIsSpecial DESC, sequence

I'm not sure how to go about fixing it?

many thanks

Adam
 
Old December 23rd, 2009, 03:27 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

It is not picking the data format correctly.

p.enddate = '31/12/2009'

change above to

p.enddate = '12/31/2009'
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
 
Old December 23rd, 2009, 04:29 AM
Authorized User
 
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
Default he conversion of a char data type to a datetime data type resulted in an out-of-range

Hi there

thanks for your reply - but p.enddate is in the format 31/12/2009?

Should it be different?

thanks

Adam
 
Old December 23rd, 2009, 07:18 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

To Use DMY format you can try the following:
SET DATEFORMAT Sets the order of the dateparts (month/day/year) for entering datetime or smalldatetime data.
Code:
SET DATEFORMAT dmy;
SELECT p.productid, p.subcategoryid, p.productname, p.partnumber, p.rrp, p.cost, p.enddate, p.weight, p.tagline, LEFT(CAST(p.extrainformation as varchar(100)), 100) AS 'extrainformation', p.imagename, p.imagename_m, p.imagename2, p.imagename3, st.id, st.stock, p.onspecial, 1 As fIsSpecial, p.sequence As sequence FROM product p, tbl_stock st WHERE DATEDIFF(day, p.enddate, GETDATE()) < 0 AND p.deleted = 0 AND p.hide = 0 AND st.id = p.stock AND p.enddate = '31/12/2009' AND p.promotionid = '9' ORDER BY fIsSpecial DESC, sequence
SET DATEFORMAT mdy;
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Char Data Type to smalldatetime rylemer SQL Language 3 March 3rd, 2005 03:13 PM
Help with data type conversion please androoo Pro VB 6 2 December 24th, 2004 05:45 PM
Help with data type conversion please androoo Pro VB.NET 2002/2003 0 November 29th, 2004 09:06 AM
Data Type Conversion using WHERE IN () Colonel Angus SQL Server 2000 14 August 18th, 2004 08:08 PM
Data Type Conversion owain SQL Language 5 October 31st, 2003 12:31 PM





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