In SQL server, how can I affect a value to an attribute given a condition, and check the condition everyday?
Let's say an order was recorded on a certain date. According to my business rule the delivery should be made no later than 10 days after the order date.
In my Delivery table, I have a status
attribute.
In my Order table, I have an orderDate
attribute.
I would like the status
value to be set based on the following logic:
if deliveryDate is null:
if today's date < orderDate + 10:
'in progress'
else :
'late'
else :
if deliveryDate > orderDate + 10:
'late'
else:
'on time'
Is there a way I can do that, and update the status
value everyday to check again if the order is late?