Adding seconds to a timestamp

I want to add seconds to a given timestamp.

An example :

This time:

Declare
       t1 timestamp = '1900-01-01 02:00:00';

Now I want to add 20 secondsat a given time.

In SQL Server, I used DATEADD. But I searched and found out that such a function is not provided by PostgreSQL.

What will be the solution?

+1
source share
1 answer

Just add 20 seconds:

t1 := t1 + interval '20' second;

The assignment operator in PL / pgSQL is :=. =exists only for backward compatibility. Do not use it.

+2
source

Source: https://habr.com/ru/post/1666271/


All Articles