Concatenate datetime fields and go to datetime postgresql

I have a table with date and time fields

Table 1

data           hora            id
2015-01-01    11:40:06          1 
2015-01-01    15:40:06          2
2015-01-02    15:40:06          3 
2015-01-05    10:40:06          4 
2015-01-05    15:40:06          5
2015-01-06    08:23:00          6

      

Now I need to consult an ID between 2015-01-01 12:00:00 12:00:00 and 2015-01-05 12:00:00, should return IDs 2,3,4. I'm trying to convert and concatenate date and time fields that are separated in the same datetime field to use "between", but I can't get into the syntax, can anyone provide an example?

+3


source to share


1 answer


It works!



SELECT
    *
FROM
    tableA
WHERE
    (dataemissao + hora) BETWEEN (date '2015-01-21' + time '14:00') 
     AND  (date '2015-01-21' + time '18:00')

      

+6


source







All Articles