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
Solved

Problem with SQL 2005 Date Statement

Posted on 2009-07-06
4
267 Views
Last Modified: 2012-05-07
Here is the Statement,
ALTER PROCEDURE [dbo].[p_ST_TimeSheet_SelectByPersonAndDate]
      @p_PersonID int,
      @p_StartDate DateTime,
      @p_FinishDate DateTime
AS
SELECT TimeSheetID, TimesheetGUID, PersonID, PersonGUID, JobID, JobGUID, JobNumber, StartDateTime, FinishDateTime, Activity, Note,
      UpdatedDate, UpdatedBy, CreatedDate, CreatedBy, isDurationPeriod, isChargeable, IsPostedToJobSheet
FROM t_ST_TimeSheet
WHERE PersonID = @p_PersonID AND StartDateTime >= @p_StartDate AND FinishDateTime < @p_FinishDate

When I try to execute
p_ST_TimeSheet_SelectByPersonAndDate 3,'01/01/1700','07/08/2001'
I get the error
Msg 8114, Level 16, State 1, Procedure p_ST_TimeSheet_SelectByPersonAndDate, Line 0
Error converting data type varchar to datetime.
Any date year >1900 is fine.  But could someone tell me how to correct this SQL statement please?
0
Comment
Question by:deeznutz
4 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 24789172
The earliest date you can pass to a datetime is January 1, 1753.
0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24789192
I guess '01/01/1700' is out of range for datetime fields - min value is 01/01/1753!
0
 
LVL 17

Expert Comment

by:pssandhu
ID: 24789227
If in SQL Server 2005 the minimum date is 1st January 1753, in SQL Server 2008 we have a new data type with minimum date 1st January 0001.
Also, check this article out on how to extend dates to include dataes less than 1753-01-01:
http://weblogs.sqlteam.com/mladenp/archive/2006/12/16/52754.aspx
Hope this helps.
P.
0
 
LVL 1

Author Closing Comment

by:deeznutz
ID: 31600356
Thanks for all responses but seeing as this was the first answer I must award points here as they are basically the same. :)
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

839 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