0

I'm trying to run a query using php pear db and is not returning any value. However, when I run using SQL Server I get the data

In PHP I'm already setting:

"SET ANSI_NULLS ON" and "SET ANSI_WARNINGS ON"

Query:

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

SOLVED

solution:

"The safe datetime string formats to use in SQL Server is

YYYYMMDD HH:MM:SS or 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
  • 1
    Please add your solution as answer. Commented Jul 8, 2013 at 9:09

1 Answer 1

2

SOLVED

solution:

"The safe datetime string formats to use in SQL Server is

YYYYMMDD HH:MM:SS or 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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.