Get a timestamp from concatenating day and time columns

casting, concatenation, datetime, postgresql, postgresql-9.1

Solution

SELECT EXTRACT(EPOCH FROM (Day || ' ' || Time)::timestamp);

Problem

I am having day and time fields in database. I want to get the time-stamp by concatenating the day and time. How to do this in PostgreSQL? I have done this: ``` SELECT EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28'); ``` And it is working fine. But when I tried replacing day and time fields I am getting the following error: ``` SELECT EXTRACT(EPOCH FROM TIMESTAMP Day || ' ' || Time); ``` ``` ERROR: syntax error at or near "Day" LINE 1: ...quest_count > 0 AND (EXTRACT(EPOCH FROM TIMESTAMP Day || ' ' || Time)) > (e... ```

Original source

Related problems