 |
| 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
|
|
|
|

December 22nd, 2009, 05:26 AM
|
|
Authorized User
|
|
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
|
|
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
|
|

December 23rd, 2009, 03:27 AM
|
|
Friend of Wrox
|
|
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
|
|
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.
|
|

December 23rd, 2009, 04:29 AM
|
|
Authorized User
|
|
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
|
|
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
|
|

December 23rd, 2009, 07:18 AM
|
|
Friend of Wrox
|
|
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
|
|
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.
|
|
 |