0

I have been trying to work this out all week. I have a table with values names start and finish. I need a Postgres query to relay the hours back to me in a nice format.

The original (before hours) query is this

select * from public.volass
where linkedass=$request_id 
order by start

So when I try and use DiffDate I make it look like

select datediff(hours,start,finish), * from public.volass
where linkedass=$request_id 
order by start

Postgres then gives me the following error.

ERROR:  column "hours" does not exist
LINE 1: select datediff(hours,start,finish), * from public.volass
                        ^
********** Error **********
ERROR: column "hours" does not exist
SQL state: 42703
Character: 17
  1. Do I need to have a field named "Hours" in the system for this to work
  2. Even if I add a field named "hours" it still stuffs up
  3. Can you steer me in the correct direction to use Difdate

1 Answer 1

1

Consider using Postgre's EXTRACT:

SELECT (EXTRACT(EPOCH FROM finish - start) / 3600) AS duration, *
FROM public.volass 
WHERE linkedass=$request_id 
ORDER BY start
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.