"I need the code for this" seems a bit too much like "Plz give meh teh codez", and your "date in the future" seems a little bit in the past.
Anyway, you should investigate the relevant methods of the DateTime
structure, in particular the Subtract method (both overloads, or in alternative its subtraction operator), and you should have a look at the TimeSpan
structure too.
You could create a DateTime
for the date of today, subtract a TimeSpan
of 7 days to it, and then subtract such result to a DateTime
representing your date in the future (or, if it is in the past, do the opposite). You'll get a TimeSpan
representing the difference in time between the two dates, from which you can easily get the number of days using its Days
property.
As other said, to do the first subtraction you can also use the AddDays
method of the DateTime
structure.