TheSQLLearner
TheSQLLearner

Reputation: 51

Using DATEDIFF(type, startdate, enddate) with values that come from other tables

All of the examples that are online are getting the DATEDIFF() using values that are hard coded.

I want to get the DATEDIFF() from 20 or 30 rows in a table that have columns named startdate and enddate.

The end goal for me is to get seconds between two dates for 20 rows... I created a variable above and SET the variable equal to DATEDIFF(SECONDS, startdate, enddate), but when I go to grab the values in the table that is holding the start and end date, I am getting errors.

Is there something I'm doing wrong, logically anyways?

Upvotes: 1

Views: 66

Answers (1)

user45867
user45867

Reputation: 977

You made seconds plural. Try datediff(second, startdate, enddate) - should work just fine.

Upvotes: 1

Related Questions