Assumeing I have a table Foo
id | startDate | startTime | endTime | name
I am trying to find occurrences that "pass midnight"...start < 00:00:00 and end > 00:00:00
I can use the following to get the times
select extract (epoch from (endTime - startTime)) as time from Foo
but how can I add a constraint that allows me to filter the return values for only those < 0 (which should be those satisfying the "midnight" property)
I tried
select extract (epoch from (endTime - startTime)) as timeSpent from Foo where timeSpent < 0
ERROR: column "timeSpent" does not exist
timeis a reserved word in PG; so pick a different namestarttimeandendtime?