Hi @JESUS EDUARDO CHAVARIN ROCHA
Because you Declare the parameter @YA AS DATETIME, while the datatype of column NoSem is nvarchar. You cannot compare values with two different datatypes.
Here are two solutions:
1)Modify the Declare statement, like this:
DECLARE @YA AS nvarchar(10) = DATEPART(ISO_WEEK, GETDATE())
SELECT @YA
SELECT * FROM Datos.dbo.HorasTrabajadas
WHERE @YA = NoSem
ORDER BY Fecha ASC
2)Modify the WHERE clause, like this:
DECLARE @YA AS DATETIME = GETDATE()
SELECT DATEPART(ISO_WEEK, @YA)
SELECT * FROM Datos.dbo.HorasTrabajadas
WHERE DATEPART(ISO_WEEK, @YA) = NoSem
ORDER BY Fecha ASC
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.