Search
 
SCRIPT & CODE EXAMPLE
 

SQL

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 diff between two dates in Months

EXTRACT(year FROM age(end_date,start_date))*12 + EXTRACT(month FROM age(end_date,start_date))
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 :: base nosql 
Sql :: sql select contem uma palavra 
Sql :: add created and updatedAt fields in mysql 
Sql :: oracle current date plus 1 month 
Sql :: select count from table mysql 
Sql :: sql select except null 
Sql :: SQL server query column yes or no 
Sql :: remove all records from table mysql 
Sql :: LoadError: cannot load such file -- mysql2/2.7/mysql2 
Sql :: sql server drop table if exists 
Sql :: oracle character set 
Sql :: datetime add 2 hours sql 
Sql :: python mysql search 
Sql :: alter table sql 
Sql :: backup mysql data only 
Sql :: hour and minute between two datatime sql 
Sql :: oracle list user grants 
Sql :: update query formula in excel 
Sql :: getting next sequence value jpa postgress 
Sql :: mysql convert column to uppercase 
Sql :: data directory postgresql 
Sql :: mysql reset root password 
Sql :: connecting to mysql database using python 
Sql :: insert all in sql 
Sql :: sql get month name 
Sql :: print all records of table in mysql 
Sql :: oracle saurce code 
Sql :: spring import sql 
Sql :: mysql update row 
Sql :: sql update table remove spaces 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =