4
I’m trying to get you to return to me the patient of a particular day and time in command next:
SqlCommand cmdSelect = new SqlCommand("select DISTINCT P.nome,P.codPaciente,
M.codMedico, C.descricao from Consulta as C " +
", Medico as M, Paciente as P where M.codMedico = C.codMedico and " +
"P.codPaciente = C.codPaciente and M.cpf = @cpf and " +
"cast(C.dataConsulta as date) = @data",conexao);
cmdSelect.Parameters.AddWithValue("@cpf", Session["cpf"]);
cmdSelect.Parameters.AddWithValue("@data", data);
But you’re returning all the patients of the day.
I tried to change as date
for as datetime
, when I do it he returns null
, tried to convert into datetime
the date and pass through but will not.
The date is being passed this way: 2018-11-10 17:35
.
I changed her to be 2018-11-10 17:35:00.000
, but it still wasn’t.
What should I do?
If the field type is Datetime then remove the cast. ex:
C.dataConsulta=@data
– William John Adam Trindade
the dataConsult column is of what type?
– Lucas Miranda
Hi William,if I remove the cast it won’t,I tried to do this by also changing the value passed on @data to datetime.but it wasn’t..
– lisa15x
the dataConsult is datetime
– lisa15x
in my view then you should not give cast to date on it so since you need the time and this will make you lose the information, the date is a string or a datetime?
– Lucas Miranda
How is the @data parameter declared? If it is a string, I suggest you use
"C.dataConsulta = convert(datetime, @data, 120)",conexao);
– José Diz