1
I’m trying to select in ms sql but I can’t use datetime.
$dataInicio = \DateTime::createFromFormat('d/m/Y', $input['data_inicio'])->format('Y-m-d');
$result = \DB::select('Select * from PESAGEM where cast(databruto as date) = ? and ativo = 1') ,[$dataInicio]);
I tried to do by querybuilder and could not also, example if I use this direct query in the bank I get return.
select * from pesagem where cast(datatara as date) = '2015-09-03' and ativo = 1
How would make a query using format datatime
?
What do you mean you can’t use datetime? try to explain your question better.
– Marconi
Well, I do not know what the problem but php does not return me anything when I do the query, the same query I do directly in the database but la passo a data entre aspas
– Raphael Barauna
Have you generated an error? If you are quoting in the database try this in php 'Select * from WEIGHING Where cast(raw date as date) = ''? '' and active = 1'
– Marconi
does not generate error, behind the empty variable, with quotes shows error in the result variable
– Raphael Barauna
What kind of column? datetime? smalldate?
– rray
It’s like datetime
– Raphael Barauna