SQL searching for records from a Date and Time

2

I have the following SQL:

select * from tb_valores
where
DATA >= '14/12/17' and
HORA >= '16:34:00')

I would like to bring all records from that date and time.

The problem is that if I have records like:

'14/12/17' '10:20:00'
'14/12/17' '13:20:00'
'14/12/17' '16:32:00'
'18/12/17' '08:00:00'

It does not have these records.

    
asked by anonymous 15.12.2017 / 20:20

3 answers

0

James, you can do something like this:

SELECT * FROM tb_valores WHERE (DATA > '14/12/17' OR (DATA = '14/12/17' AND HORA >= '16:34:00'))

In this way the query will fetch all data with a date greater than "12/14/17", which consequently will be greater than "12/14/17 16:34:00", or data with date equal to " 14/12/17 "plus hour greater or equal to" 16:34:00 ".

    
26.12.2017 / 21:22
0

So it does not work?

select * from tb_valores where (DATA >= '14/12/17 '') and ( HORA >= '16:34:00') 
    
15.12.2017 / 20:29
0

James, The Jovani code runs, I validated it now.

Just take a quote right after 17, which works.

Leave it like this:

    select * from tb_valores where (DATA >= '14/12/17') and ( HORA >= '16:34:00') 

Instead of this:

    select * from tb_valores where (DATA >= '14/12/17 '') and ( HORA >= '16:34:00')

If it still does not work, send the Create Statment from your table.

    
19.12.2017 / 15:08