不允许从数据类型datetime隐式转换为数据类型float,table' TABLE',column' FECHA'。使用CONVERT函数运行此查询

时间:2015-02-05 20:02:00

标签: sql-server datetime stored-procedures

我有这个错误,我无法解决它

Msg 260,Level 16,State 3,Procedure SP_SAV_ESTADISTICALLAMADAXOPERADOR,Line 7 不允许从数据类型datetime隐式转换为数据类型float,table' APEX.SAV_LLAMADAS',column' FECHA'。使用CONVERT函数运行此查询。

这是我的代码

CREATE PROCEDURE APEX.SP_SAV_ESTADISTICALLAMADAXOPERADOR
    @pCodOperador   VARCHAR (20) 
AS 
    BEGIN
        SET NOCOUNT ON

        SELECT  TP.DESCRIPCION AS TIPOLOGIA,
                ST.DESCRIPCION AS SUB_TIPOLOGIA,
                COUNT(*) AS TOTAL
        FROM    APEX.SAV_LLAMADAS_DET DT INNER JOIN APEX.SAV_LLAMADAS LL 
        ON      LL.ID_LLAMADA  = DT.ID_LLAMADA  INNER JOIN APEX.SAV_SUB_TIPOLOGIAS ST 
        ON      DT.COD_TIPOLOGIA  = DT.COD_TIPOLOGIA
         AND    DT.COD_SUBTIPOLOGIA  = ST.COD_SUB_TIPOLOGIA  INNER JOIN APEX.SAV_TIPOLOGIAS TP 
        ON      TP.COD_TIPOLOGIA  = ST.COD_TIPOLOGIA  
        WHERE   DT.USUARIO_CREA  = @pCodOperador
         AND    FLOOR(LL.FECHA)  = FLOOR((GETDATE()))
        GROUP BY TP.DESCRIPCION, ST.DESCRIPCION 

        SET NOCOUNT OFF

    END

1 个答案:

答案 0 :(得分:1)

您无法在日期时间数据类型上执行FLOOR。假设你试图排除日期时间的时间部分,你可以做这样的事情。

AND CAST(LL.FECHA AS DATE)  = CAST(GETDATE() AS DATE)