I need to pull values from one table that are only 24 hours from the date in another table in sybase ase 15.5.
Here is my wrong code:
SELECT p_generaldata.admissiontime,*
FROM Patient.dbo.P_MonVals P_MonVals
INNER JOIN Patient.dbo.P_GeneralData P_GeneralData
ON P_MonVals.PatientID=P_GeneralData.PatientID
where p_generaldata.admissiontime < P_MonVals.entertime +1
order by p_generaldata.patientid ASC
Im trying to return all rows in p_monvals, where the entertime in that table is less than 24 hours after the admissiontime.
the error im getting is INT is not compatible with DATETIME
Any help greatly appreciated
thank you
Take a look a the DateAdd
function, and add a day to the entertime
Example from docs:
Adds one day to a date:
declare @a date
select @a = "apr 12, 9999"
select dateadd(dd, 1, @a)
In your case...
...
where p_generaldata.admissiontime < dateadd(dd, 1, P_MonVals.entertime)