Last post Aug 15, 2015 05:12 PM by Rion Williams
Aug 15, 2015 12:59 PM|volar5|LINK
I need a formula that gives if the number of days let to a product to be annulled is within a period. The product can be annulled within 7 days since the buy.
But it is not correct. @diasanulaciones is the 7 period of annullment. fecha is the date of buy. Can u help me?
Aug 15, 2015 05:12 PM|Rion Williams|LINK
So you want to get the difference between today's date and your purchase date (fecha) plus whatever your annullment period is? If that is the case, you should be able to use the following to determine how many days are "left" for each of your records :
DATEDIFF(d,GETDATE(),DATEADD(d,@diasanulaciones,fecha)) AS DaysRemaining
You can see a working example here that uses a hard-coded value for @diasanulaciones :
As you can see if the value returned is negative then the item has already "expired".