Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 operand type clash error

Author  Topic 

Arun.G
Yak Posting Veteran

81 Posts

Posted - 2010-07-20 : 03:45:36
create PROCEDURE [dbo].[SP_TA_ATTENDANCE_ADD]

-- The below are the input arguments for calling the procedure


@TA_TYPE INTEGER,
@EMPLOYEEID VARCHAR(50),
@DATE DATE,
@INTIME TIME(0),
@OUTTIME TIME(0)

AS

begin
INSERT INTO MASTER_ATTENDANCE
(MONTH,YEAR,WEEK,WEEKSTART,WEEKEND)
VALUES
(
MONTH(@DATE),
YEAR(@DATE),
DAY(Datepart(day, @DATE - 1) / 7 + 1),
DAY(dateadd(wk,0,dateadd(wk,DATEDIFF(WK,0,@DATE,0)))),
DAY(dateadd(wk,1,dateadd(wk,DATEDIFF(WK,1,@DATE),0))-1)
);

INSERT INTO TA_ATTENDANCE
(
TA_TYPE,
EMPLOYEEID,
ATTENDANCEID,
INTIME,
OUTTIME,
TOTALTIME,
DAYOFWEEK
)

VALUES
(
@TA_TYPE,
@EMPLOYEEID,
(SELECT ATTENDANCEID FROM MASTER_ATTENDANCE WHERE MONTH=MONTH(@DATE)AND YEAR=YEAR(@DATE)AND WEEKSTART>=DAY(@DATE)AND WEEKEND<=DAY(@DATE)),
@INTIME,
@OUTTIME,
DATEDIFF(HOUR,@OUTTIME,@INTIME),
DATENAME(DW,@DATE)
);
end

the above is my sp, using the sp, im inserting values into two tables by getting date as input arguement,

if i try to execute this sp, its throwing the error like:

Operand type clash: date is incompatible with int

but in master attadance tables all the columns(monh,year,week,weekstart,weekend) all are integer datatype only

wat i have to do? using CAST v can solve this or anyother methid?

Kristen
Test

22859 Posts

Posted - 2010-07-20 : 04:03:56
DAY(Datepart(day, @DATE - 1) / 7 + 1)

Don't think you can do that can you?

DAY(dateadd(wk,0,dateadd(wk,DATEDIFF(WK,0,@DATE,0))))

should only be 3 parameters to DATEDIFF function
Go to Top of Page

Arun.G
Yak Posting Veteran

81 Posts

Posted - 2010-07-20 : 04:57:01
I want to get weekno.

for example:

if the date is : '2010-07-20' means the week should be : 4


wats is the query for that?
Go to Top of Page

sql-programmers
Posting Yak Master

190 Posts

Posted - 2010-07-20 : 07:31:06
Use the script,
Select datepart(w,getdate())

But it results only 3. It takes only the hole week count.

SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page
   

- Advertisement -