2
I have a table with the structure below
I need to make an appointment with a certain interval in order to generate a report. I used the Between command... and with it it returns me the following values
However for the interface I need to present in the form dd-mm-yyyy and not as the saved seat which is yyyyyy-mm-dd.
I’ve used the remote
select * from venda where data_venda = DATE_FORMAT('18-01-2016', '%d-%m-%Y')
SELECT * FROM venda WHERE STR_TO_DATE(data_venda, '%d-%m-%Y') BETWEEN STR_TO_DATE('2016/01/18','%d-%m-%Y') AND STR_TO_DATE('2016/02/15','%d-%m-%Y')
But always returns a null value.
Has anyone there ever done that and could help me?
There is a confusion in the question. One thing is the format to show on the screen, which is what comes after SELECT and before FROM. Another is what you use in research, in WHERE. If you want to display differently, exchange that asterisk for the desired field with the desired formatting, and let WHERE work in the correct format ( yyyy-mm-dd ). How to search between two dates has already been answered here: http://answall.com/questions/4177/
– Bacco
Could you describe how you would look out of kindness? What I need is for you to return to the correct format because I am filling a jTable with the result of select.
– Valdecir
SELECT DATE_FORMAT( data_venda, '%d-%m-%Y') AS datavenda FROM venda WHERE data_venda BETWEEN '2016-01-18' AND '2016-02-15'
To use more fields, you can put before the DATE_FORMAT, or after the AS data sale, separating with comma– Bacco