Mark Randy
Mark Randy

Reputation: 95

Insertion syntax for interval data type in postgres

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;

Upvotes: 7

Views: 8550

Answers (1)

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.

Upvotes: 5

Related Questions