leora
leora

Reputation: 196469

get number of weeks away from today

i have a date in the future and i want to find out how many weeks away this is.

Upvotes: 3

Views: 256

Answers (2)

Fermin
Fermin

Reputation: 36081

I think you'd be best getting the no of days and dividing that by 7

DateTime start = DateTime.Now;
DateTime end = DateTime.Now.AddDays(21);

double noOfDays = (end - start).TotalDays;
double noOfWeeks = noOfDays  / 7;

Upvotes: 1

Tim Robinson
Tim Robinson

Reputation: 54734

(futureDate - DateTime.Today).TotalDays / 7

Upvotes: 6

Related Questions