开发者

get number of weeks away from today

开发者 https://www.devze.com 2022-12-22 08:32 出处:网络
i have a date in the future and i want to find out how many weeks awa开发者_Python百科y this is.(futureDate - DateTime.Today).TotalDays / 7

i have a date in the future and i want to find out how many weeks awa开发者_Python百科y this is.


(futureDate - DateTime.Today).TotalDays / 7


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消