SELECT for date format dd / mm / yyyy hh: mm: ss

2

Inquiry

SELECT 
campo
FROM 
Tabela
WHERE data BETWEEN '2016-10-20' AND '2016-10-20'

data and a field with type datetime , I'm having problems with records for example that have the following value:

2016-10-20 19:00:00

Dates with this value type do not appear in the query.

What would be the appropriate form of query for the yyyy/MM/dd/ hh:mm:ss format? being that the user only chooses the initial and final date in the format dd/MM/yyyy

    
asked by anonymous 21.10.2016 / 14:03

1 answer

4

Use the Date () function, which works more or less like TRUNC() of Oracle.

SELECT 
campo
FROM 
Tabela
WHERE Date(data) BETWEEN '2016-10-20' AND '2016-10-20'
    
21.10.2016 / 14:14