Reputation: 41
consider i have a table named Products
.
ProductID |
ProductName |
ExpDate |
---|---|---|
1001 | Coca Cola | 2021-6-6 |
1002 | Pepsi | 2021-5-8 |
I wanted to get the ExpDate
from each of the Products
and get the 30 days before that date.
for example; the 1st one ExpDate
is 2021-6-6, so minus 30 days = 2021-5-5
Upvotes: 0
Views: 349
Reputation: 197
You can use DateAdd function to subtract 30 days from a date field.
Select ProductName, ExpDate, dateadd(day,-30,ExpDate) as '30Daysbefore'
from Products
Upvotes: 1