Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Weird Error Msg 296: conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value

Posted on 2004-10-14
5
Medium Priority
?
5,116 Views
Last Modified: 2008-01-09
SELECT S.StudentID, S.FirstName+' '+S.LastName AS SName, S.EnrollDate , PRs.RecieptID, PRs.TutionFee AS AmountPaid, PRs.PaymentDate, PRs.PaymentMode, PRs.CheckNo, PRs.Comments , PRs.CreditCardName FROM PaymentReciepts AS PRs INNER JOIN Students AS S ON (PRs.LocationID = S.LocationID) AND (PRs.StudentID = S.StudentID) WHERE (((PRs.PaymentDate) Between '09/01/2004' And '09/31/2004' )) ORDER BY PaymentDate Desc

Gives error: Server: Msg 296, Level 16, State 3, Line 1
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.

HOWEVER - this is not giving an error:
SELECT S.StudentID, S.FirstName+' '+S.LastName AS SName, S.EnrollDate , PRs.RecieptID, PRs.TutionFee AS AmountPaid, PRs.PaymentDate, PRs.PaymentMode, PRs.CheckNo, PRs.Comments , PRs.CreditCardName FROM PaymentReciepts AS PRs INNER JOIN Students AS S ON (PRs.LocationID = S.LocationID) AND (PRs.StudentID = S.StudentID) WHERE (((PRs.PaymentDate) Between '10/01/2004' And '09/10/2004' )) ORDER BY PaymentDate Desc
0
Comment
Question by:MargusLehiste
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:SNilsson
ID: 12310880

Check the PRs.PaymentDate column is the data type smalldatetime ?

If not, check the dates between '09/01/2004' And '09/31/2004' some charactor that dont belong might have slipped in the wrong place.

0
 
LVL 8

Expert Comment

by:MartinCMS
ID: 12310885
try....

WHERE Convert(Varchar(10), PRs.PaymentDate,101) Between '09/01/2004' And '09/30/2004'
ORDER BY PaymentDate Desc
0
 
LVL 8

Accepted Solution

by:
MartinCMS earned 2000 total points
ID: 12310890
September only have 30 days.
0
 
LVL 8

Expert Comment

by:SNilsson
ID: 12310953

 "September only have 30 days."

Right on :)

I did not notice, we use the YYYY-MM-DD formate in my country, nice spotted.
0
 
LVL 1

Author Comment

by:MargusLehiste
ID: 12313159
Gee - what was I thinking ....

(Anyway - my application needs better error checking)
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question