add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table Ingredients (ing_id int not null,
ing_name varchar(40), preserve_time int, ing_bought date, freshness int,
primary key (ing_id));

insert into Ingredients values (1, "Meat", 18, "2020-10-20", null);



select * from Ingredients
ing_id ing_name preserve_time ing_bought freshness
1 Meat 18 2020-10-20 null
update Ingredients set freshness = 100 - (DATEDIFF(now(), ing_bought) / preserve_time) * 100
where ing_id = 1;
select *, DATE(NOW()) as today, DATEDIFF(now(), ing_bought) as days from Ingredients
ing_id ing_name preserve_time ing_bought freshness today days
1 Meat 18 2020-10-20 6 2020-11-06 17