Xyltic
Xyltic

Reputation: 123

How can I apply time difference between 2 TIMESTAMPS in SQL/Impala?

I have two columns (both TIMESTAMPS as value)

start date          | end date
2017-11-29 19:45:00 | 2017-11-29 20:13:00

I want to see the difference in minutes.

I've tried

SELECT UNIX_TIMESTAMP('end date') - UNIX_TIMESTAMP('start date') as mindiff

but that did not work.

How can I do this in SQL / Impala

Upvotes: 0

Views: 2928

Answers (1)

Xyltic
Xyltic

Reputation: 123

I have found the mistake.

SELECT UNIX_TIMESTAMP('end date') - UNIX_TIMESTAMP('start date') as mindiff

the quotes sees it as a text (actually manually fill the date) but for mentioning the columns I need to remove the ''.

So it should be

SELECT UNIX_TIMESTAMP(end date) - UNIX_TIMESTAMP(start date) as mindiff

Upvotes: 3

Related Questions