I have created a trigger to set the time value of a Column of data type time() to NULL when ever it is greater than GETDATE().
I am getting an error which indicates a conflict between the columns’ data type time() and GETDATE() since GETDATE() retrieves date and time.
My question is how can I get the time portion only of the GETDATE() to use it in my trigger?
Trigger Code:
create trigger trig1
on [dbo].[Products]
after insert
as
update Products
set ParkingStartTime = null
from Products
join inserted i
on i.ParkingStartTime = Products.ParkingStartTime
where i.ParkingStartTime >= GETDATE();
Regards.
based on the comment, you cannot implicitly cast time to datetime – so you need to convert it manually: