简体   繁体   中英

Using DATADIFF in a query (PL/SQL)

I'm trying to use a DataDiff in a query so that I can also "print" the difference between the two dates, in seconds. The query looks like this:

SELECT vr.CodeR, vi.DateU, vl.originU, vl.destinyU, (DATEDIFF(second,vi.plannedDate,vi.SetDate) AS DiffDate)
FROM RegularU vr, Connection vl, InstantU vi
WHERE vl.codeU=vr.codeU AND vr.CodeR=vi.CodeR

But when I try to run it I have the error "Missing select word". Is there a way so that I can do this in a query?

Thanks in advance

You should better calculate a difference in seconds between two dates:

SELECT vr.CodeR, vi.DateU, vl.originU, vl.destinyU, (vi.plannedDate - vi.SetDate)*24*60*60  AS DiffDate
FROM RegularU vr, Connection vl, InstantU vi
WHERE vl.codeU=vr.codeU AND vr.CodeR=vi.CodeR

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM