Search
 
SCRIPT & CODE EXAMPLE
 

SQL

postgres date difference seconds

-- difference in seconds between two dates

select extract(epoch from ('2020-03-30 09:55:56'::timestamp - '2020-03-30 08:54:55'::timestamp));
-- result : 3661
Comment

postgresql get difference between two dates

select age('2010-04-01', '2012-03-05'),
       date_part('year',age('2010-04-01', '2012-03-05')),
       date_part('month',age('2010-04-01', '2012-03-05')),
       date_part('day',age('2010-04-01', '2012-03-05'));
Comment

postgresql get difference in hours between two dates

select EXTRACT(
	EPOCH FROM now() - (now() - INTERVAL '5 HOUR')
)/3600

-- it will return 5
Comment

PREVIOUS NEXT
Code Example
Sql :: sql server delete top 1000 
Sql :: script to add new column in table sql 
Sql :: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client 
Sql :: mysql change primary key 
Sql :: host is not allowed to connect to this mysql server 
Sql :: mysql query unique column 
Sql :: mysql select where not in multiple tables 
Sql :: show tables postgresql 
Sql :: create table sql 
Sql :: using distinct count in sqlite3 
Sql :: oracle grant select on schema 
Sql :: sql delete multiple conditions 
Sql :: combine two columns using sql query 
Sql :: if not exists insert sql 
Sql :: mysql check db size 
Sql :: XOR in SQL Server 
Sql :: mysql user change password 
Sql :: oracle alter table delete column 
Sql :: epoch time converter in snowflake 
Sql :: start postgres server 
Sql :: sql timestamp to date 
Sql :: postgresql update between 2 tables 
Sql :: oracle pl sql source 
Sql :: create index concurrently postgres 
Sql :: alter table add column forigen key mysql 
Sql :: sql offset 
Sql :: sql server get schema of table 
Sql :: mysql extract month from date 
Sql :: create pl/sql stored procedure 
Sql :: SQL Auto Increment Primary Key - SQL Server 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =