7

I created a table with following the fields and I have used a interval field to store duration of the courses. I want to insert interval time in DD:HH and couldn't find the syntax for it.

Anybody can help me with this insertion syntax with above format DD:HH . Thanks in advance.

CREATE TABLE practical.course
(
  course_id character(3) primary key,
  course_name character varying(30),
  duration interval,
  dept_id integer references practical.department(dept_id)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE practical.course
  OWNER TO postgres;
2

1 Answer 1

5

You can insert as follows..

insert into practical.course(course_id,course_name, duration, dept_id)
values('104','Mathematical Engineering','40:00:00',1);

If you want to add days you can add 'no_of_days 40:00:00' instead '40:00:00'. You can insert in different formats and they are available in above link on the comment.

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.