Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to calculate number of weeks given 2 dates?

Tags:

c#

datetime

I have two DateTime variables and i need to compute number of weeks between them.

What is the quickest (and correct) way to do this?

like image 320
leora Avatar asked Jan 05 '11 12:01

leora


1 Answers

Use TimeSpan:

double weeks = (date1 - date2).TotalDays / 7;
like image 152
Oded Avatar answered Oct 08 '22 01:10

Oded