accesser2003
Registered User.
- Local time
- Today, 11:02
- Joined
- Jun 2, 2007
- Messages
- 124
I have a SQL Server database. I buildt a stored procedure FindPSF as follow:
CREATE PROCEDURE dbo.FindPSF(@Ix int)
AS SELECT Indx, AttDay, Start, Finish, DATEDIFF(day, Start, Finish)
FROM dbo.SelectedEmployeesWorkMode
WHERE (Indx = @Ix) AND (NOT (Start IS NULL)) AND (NOT (Finish IS NULL)) AS count_of_days
The structure of the tabel [dbo.SelectedEmployeesWorkMode] is as follow:
CREATE TABLE [dbo].[SelectedEmployeesWorkMode] (
[Indx] [int] NOT NULL ,
[AttDay] [smalldatetime] NOT NULL ,
[WorkMode] [nvarchar] (50) NOT NULL ,
[RosterCode] [nvarchar] (50) NULL ,
[Start] [nvarchar] (50) NULL ,
[Finish] [nvarchar] (50) NULL
)
When I run the PSF stored procedure, it gives me this strange error:
"Arithmetic overflow error converting expression to data type datetime"
It is really strange error as the DATEDIFF function is a simple one. Please help. Thanks in advance.
CREATE PROCEDURE dbo.FindPSF(@Ix int)
AS SELECT Indx, AttDay, Start, Finish, DATEDIFF(day, Start, Finish)
FROM dbo.SelectedEmployeesWorkMode
WHERE (Indx = @Ix) AND (NOT (Start IS NULL)) AND (NOT (Finish IS NULL)) AS count_of_days
The structure of the tabel [dbo.SelectedEmployeesWorkMode] is as follow:
CREATE TABLE [dbo].[SelectedEmployeesWorkMode] (
[Indx] [int] NOT NULL ,
[AttDay] [smalldatetime] NOT NULL ,
[WorkMode] [nvarchar] (50) NOT NULL ,
[RosterCode] [nvarchar] (50) NULL ,
[Start] [nvarchar] (50) NULL ,
[Finish] [nvarchar] (50) NULL
)
When I run the PSF stored procedure, it gives me this strange error:
"Arithmetic overflow error converting expression to data type datetime"
It is really strange error as the DATEDIFF function is a simple one. Please help. Thanks in advance.