Skip to content
Advertisement

How do you I calculate the difference between two timestamps in PostgreSQL?

I have a SELECT query to retrieve data I need. One of the needed data is a an “aggregate” function to select two timestamp dates and calculate the difference between them. Using several resources and websites, they all gave me save answer and it did not work:

I’m getting an error on the “@”: syntax error at or near “@” (This is a portion of the code only but the error is here)

Advertisement

Answer

You can take the differenc in Postgres:

I’m not sure why you are using SQL Server syntax for this. Nor do I know what timestampdiff is supposed to be.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement