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:
DECLARE @DATE1 TIMESTAMP = actual_route.end_location_time
DECLARE @DATE2 TIMESTAMP = actual_route.actual_trip_start_time
SELECT
CONVERT (TIMESTAMPDIFF, @DATE1, @DATE2) AS time_taken, actual_route.time as date_time
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)
You can take the differenc in Postgres:
select (actual_route.end_location_time - actual_route.actual_trip_start_time) as duration
I'm not sure why you are using SQL Server syntax for this. Nor do I know what timestampdiff
is supposed to be.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.