如何计算给定2日期周数? [英] how to calculate number of weeks given 2 dates?
本文介绍了如何计算给定2日期周数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个日期时间变量,我需要计算两者之间的周数。
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?
推荐答案
使用的 时间跨度
:
int weeks = (date1 - date2).TotalDays / 7;
这篇关于如何计算给定2日期周数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文