0
I’m making a screen in php where the user has the date filter to extract a report from the database SQL Server, but the Mysql displays the default date mm/dd/yyyy, and I need him to turn dd/mm/yyyy in the between
, someone knows how to make this conversion?
Follow the way I tried:
SELECT p.idProcesso, p.Usr_id, p.Usr_name
, p.Usr_CPF, p.crd_snr, t.dsPunicao
, convert(varchar, p.dtCadastro, 103)+' '+convert(varchar, p.dtCadastro, 108) dtCadastro
, s.dsStatusProcesso
, p.idStatusProcesso
FROM tmProcesso AS p
INNER JOIN tcStatusProcesso as s
on p.idStatusProcesso = s.idStatusProcesso
INNER JOIN tcPunicao as t
on p.idPunicao = t.idPunicao
WHERE p.app_id = '$var_appid'
and p.dtCadastro between CONVERT(VARCHAR, '$var_dtini', GETDATE(), 103)
and CONVERT(VARCHAR, '$var_dtfim', GETDATE(), 103)"
I don’t know if this way is right, I’d like to confirm, if it’s too obvious, forgive me.
In Mysql and PHP I use this way for date queries, and it works: DATE_FORMAT(r.DATA_SAIDA, '%d-%m-%Y') the date, where the date in the database is as mm/dd/yyyy and select I turn to dd/mm/yyyy
– Diego
@Lidianefernandes Is it Mysql or SQL Server? You quote Mysql in the text but the functions are SQL Server. // How is the column declared
p.dtCadastro
? // The format of$var_dtfim
is dd/mm/yyyy?– José Diz
@Josédiz is SQL Server, MSSQL. Its database format is mm/dd/yyyy
– Lidiane Fernandes
Fixing, up there appears Mysql even, but it is MSSQL.
– Lidiane Fernandes