| 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)ASbeginINSERT 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));endthe 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 intbut in master attadance tables all the columns(monh,year,week,weekstart,weekend) all are integer datatype onlywat 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 |
 |
|
|
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 : 4wats is the query for that? |
 |
|
|
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 Consultantshttp://www.sql-programmers.com/ |
 |
|
|
|
|
|