How to change the date format for the between to work

Asked

Viewed 33 times

0

I have a form type date , which returns values of type 2019-10-24 , however in my database is recorded as 20191024 , this implies that if the user puts in a search two dates equal my between does not work. But in case he puts different dates it works.

$query = ("SELECT * FROM TESTTE WHERE DT_EMISSAO BETWEEN '$data_inicial' AND '$data_final' ORDER BY FILIAL");

1 answer

1

What I did and solved :

$data_inicial = explode('-', $data_inicial);     // transforma em array
$data_inicial = implode('', $data_inicial);     // transforma em string novamente
$data_final = explode('-', $data_final);     // transforma em array
$data_final = implode('', $data_final);     // transforma em string novamente
  • A link that may help you: http://www.consultoriadba.com/post/2017/08/23/fun%C3%A7%C3%B5es-de-data-no-sql-server and this involving with PHP http://www.devwilliam.com.br/php/10-funcoes-php-worke-time

Browser other questions tagged

You are not signed in. Login or sign up in order to post.