在我的Excel工作表中,我想计算4周开始/结束的日期。
我有这个公式来根据在C9,H9 (= C9+1)
,C23 (=H9+1)
,H23 (=C23+1)
中输入的周数来计算星期一和星期日的日期:
星期一
=IF(C9<>"",DATE(YEAR(TODAY()),1,-2)-WEEKDAY(DATE(C9,1,3))+C9*7,"")
=IF(H9<>"",DATE(YEAR(TODAY()),1,-2)-WEEKDAY(DATE(H9,1,3))+H9*7,"")
=IF(C23<>"",DATE(YEAR(TODAY()),1,-2)-WEEKDAY(DATE(C23,1,3))+C23*7,"")
=IF(H23<>"",DATE(YEAR(TODAY()),1,-2)-WEEKDAY(DATE(H23,1,3))+H23*7,"")
周日
=IF(C9<>"",DATE(YEAR(TODAY()),1,-2)-WEEKDAY(DATE(C9,1,3))+C9*7+6,"")
=IF(H9<>"",DATE(YEAR(TODAY()),1,-2)-WEEKDAY(DATE(H9,1,3))+H9*7+6,"")
=IF(C23<>"",DATE(YEAR(TODAY()),1,-2)-WEEKDAY(DATE(C23,1,3))+C23*7+6,"")
=IF(H23<>"",DATE(YEAR(TODAY()),1,-2)-WEEKDAY(DATE(H23,1,3))+H23*7+6,"")
现在,如果我在C9中输入37,则第37周的星期一和星期日正确计算为9月12日和18日,而第38周及以后的错误(9月18日和9月24日)。 错误在哪里?
答案 0 :(得分:1)
有几点需要考虑w.r.t. //***** Get list of all files/directories on the file share*****//
// List all files/directories under the root directory.
Console.WriteLine("Getting list of all files/directories under the root directory of the share.");
IEnumerable<IListFileItem> fileList = cloudFileShare.GetRootDirectoryReference().ListFilesAndDirectories();
// Print all files/directories listed above.
foreach (IListFileItem listItem in fileList)
{
// listItem type will be CloudFile or CloudFileDirectory.
Console.WriteLine(" - {0} (type: {1})", listItem.Uri, listItem.GetType());
}
Console.WriteLine("Getting list of all files/directories in the file directory on the share.");
可能您使用了site中的公式。
=IF(C9<>"",DATE(YEAR(TODAY()),1,-2)-WEEKDAY(DATE(C9,1,3))+C9*7,"")
---&gt;这里B2和A2是不同的,而你在公式中指的是同一个单元格。
在您的公式中---将=DATE(A2, 1, -2) - WEEKDAY(DATE(A2, 1, 3)) + B2 * 7
替换为WEEKDAY(DATE(H9,1,3))
。它会起作用。