Identifier

Oracle 10g:SELECT TraineeTBL.LastName,TraineeTBL.FirstName,AptBuildingTBL.BuildingN ame,AptTBL.AptNumber,AptTypeTBL.ApartmentType,AptTypeTBL.PricePerNight,AptRentalTBL.CheckInDate,AptRentalTBL.CheckOutDat e,DATEDIFF(d,AptRentalTBL. CheckInDat e,AptRent alTBL.Che ckOutDate).(PricePer Night-(Con tractDisco unt.100)) AS TotalFROM EmployerTBL INNER JOIN TraineeTBLON EmployerTBL.EmployerID = TraineeTBL.EmployerIDINNER JOIN AptRentalTBLON TraineeTBL.TraineeID = AptRentalTBL.TraineeIDINNER JOIN AptTBLON AptTBL.AptID = AptRentalTBL.AptIDINNER JOIN AptTypeTBLON AptTypeTBL.AptTypeID = AptTBL.AptTypeIDINNER JOIN AptBuildingTBLON AptBuildingTBL.BuildingI D = AptTBL.BuildingID;If I leave out the DATEDIFF line then this works.

I want the datediff to calculate the number of days for a stay and then do the calculation for the cost. What am I doing wrong?

Posted by2 years ago
Archived

There seems to be a couple ways to do this, I'm just running into trouble.

SELECT DATEDIFF(day,'2008-06-05','2008-08-05') AS DiffDate from dual is not working in SQL. ERROR: ORA-00904: 'DATEDIFF': invalid identifier. Datediff is not an Oracle function Try MONTHSBETWEEN and divide by 12: noOfYears AS (MONTHSBETWEEN (sysdate, installationDate)/12 ), Alan PS If you find this answers your question or is at least helpful, please mark it as such.

The date format is DD-MON-YR, ie 13-NOV-16. What I need to do is write a query that will compare two dates, date1 & date2, and display all where date2 is 2 days greater than date1. I think that made sense.

Mitsoda said 'There's this idea of how much Seattle can change before it's no longer Seattle. The project's internal code name was 'Project Frasier' (a reference to the Seattle-based ).Ellison described that the story and in-game factions were influenced by the conflicts over Seattle's modern identity, between its traditional music and culture and the modern developments brought by large corporations. Ellison said that they wanted to move away from what she considered to be the 'male power fantasy' of Bloodlines to give it a broader appeal. Vampire the masquerade bloodlines clans. So we made the factions aspects of the old and the new.'

Here's the relevant part of the query. OrderDate and ShippedDate are in that same format above, but I'm not sure

I know I can display all of a specific date, such as 'WHERE OrderDate='13-JUL-15', but I'm not sure how to compare the two dates.

Ora-00904:

This is Oracle SQL. Ft ir accessories.

11 comments