本文介绍了VBA将日期转换为星期数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在VBA中,我要将日期为03/11/2017(DD / MM / YYYY)转换为该日期的星期数。
In VBA I want to convert a date as 03/11/2017(DD/MM/YYYY) into the week number for that date.
直到现在我具有以下代码:
Until now I have the following code:
'geting the date out of the string HeadlineTemp = Mid(VRHeadline, InStr(VRHeadline, "[") + 1, 10) 'switch "." to "/" HeadlineTemp = Replace(HeadlineTemp, ".", "/") 'convert to a date FristVRFirstKW = CDate(HeadlineTemp)现在,我需要一个函数将该日期转换为一年中的星期数。第一个工作日是星期一。
Now, I need a function to convert that date into the week number of the year. First week day is Monday.
推荐答案要将第一个星期作为星期一,请使用以下命令:
To make the Week Number with Monday as a first day, use the following:
WorksheetFunction.WeekNum(now, vbMonday)更多推荐
VBA将日期转换为星期数
发布评论