To begin with, in MySQL dialect GetDate()
becomes CURDATE()
and IIF
becomes IF
.
Furthermore, I suggest that you use BETWEEN
for checking for a range of values: this changes the behavior on Begin_Date and End_Date (the warranty will be valid including these dates) but maybe this is also what you'd prefer.
You could use a table and a view on the top of it as the following:
CREATE TABLE Warranty(
Warranty_ID varchar(5),
Begin_Date date,
End_Date date,
Terms varchar(15),
Primary Key (Warranty_ID));
CREATE VIEW vw_Warranty AS
SELECT
Warranty_ID,
Begin_Date,
End_Date,
Terms,
IF(CURDATE() BETWEEN Begin_Date AND End_date, 'valid', 'not valid') as IS_Valid;