I have a table that has a DATETIME
name type field AppointmentDate
where it saves data with format 2022-07-27 21:32:54.420
and another field of TIME
name type EndHour
and saves data with format 13:00:00.0000000
.
So you needed a query to update the records where the date is Less than or Equal to field AppointmenDate
and Greater than field EndHour
.
I implemented this code, but it's not working for me, because what I needed was for it to compare AppointmentDate
only the date part against the field and EndHour
only the time part against the field. (I thought that only comparing AppointmentDate against the current date would do it but it doesn't work, you should also include the comparison against EndHour but I don't know how to do it)
UPDATE ScheduledVirtualAppointments SET IdState = @idStateDone , DateUpdate = GETDATE(), IdUserUpdate = 1
WHERE AppointmentDate < GETDATE() AND
IdState NOT IN (@idStateDone,@idStateRejection,@idStateCancellation,@idStateQuizAnswers)
How can i fix this?