不同的结果 - SQL Server和PHP(PEAR DB)

时间:2013-07-04 18:02:42

标签: php sql sql-server pear

我正在尝试使用php pear db运行查询,并且没有返回任何值。但是,当我使用SQL Server运行时,我得到了数据

在PHP中我已经设置了:

“SET ANSI_NULLS ON”和“SET ANSI_WARNINGS ON”

查询:

select A.nome, count(sa.id_sala) as Atendimentos, cast( avg( case when (coalesce(sa.dt_final, sa.dt_ping_internauta) > sa.dt_inicio_atendimento) then datediff(minute, coalesce(sa.dt_inicio_atendimento, sa.dt_inicio), coalesce(sa.dt_finalAtendimento, coalesce(sa.dt_final, sa.dt_ping_internauta)) ) else 0 end ) as money) as [media em minutos] from sala SA join atendente A on (A.id_atendente = SA.fk_id_atendente) where sa.interno = 0 and coalesce(sa.dt_inicio_atendimento, sa.dt_inicio) between '2012-01-01' and '2012-12-31' and SA.fk_id_empresa = 1 group by A.nome order by 2 desc

解决

溶液:

  

“在SQL Server中使用的安全日期时间字符串格式是

     

YYYYMMDD HH:MM:SS或YYYY-MM-DDTHH:MM:SS。“

SQL Error : The conversion of a varchar data type to a datetime data type resulted in an out-of-range value

1 个答案:

答案 0 :(得分:2)

解决

溶液:

  

“在SQL Server中使用的安全日期时间字符串格式是

     

YYYYMMDD HH:MM:SS或YYYY-MM-DDTHH:MM:SS。“

SQL Error : The conversion of a varchar data type to a datetime data type resulted in an out-of-range value