Search code examples
sqlpostgresqlsqldatatypes

What datatype is a datediff in Postgres sql


I have a postgres sql DB i want to insert date difference variable in a table I am doing

INSERT INTO new_table (timediff)
values ('0 days 00:00:00.000000000')

It throws an error

ERROR:  invalid input syntax for type abstime: "0 days 00:00:00.000000000"

what data type is this and how to insert the row in the table


Solution

  • Postgres has full support for interval data types. This works:

    create table new_table (timediff interval);
    
    insert into new_table (timediff)
        values ('0 days 00:00:00.000000000'::interval);