简体   繁体   English

如何查找给定日期的开始日期?

[英]How to find the start date of week from a given date?

I have a concern is that I want from a given date to retrieve the start date of the week for example: 15/04/2015 So the beginning of the week will: 13/04/2015 (for me the beginning of the week is Monday). 我担心的是,我希望从给定日期检索一周的开始日期,例如:2015年4月15日所以本周的开头将:2015年4月13日(对我来说,本周的开始是星期一)。

thanks 谢谢

Try this :-) 试试这个 :-)

Dim FirstDayInWeek, LastDayInWeek  As Variant
Dim dtmDate As Date
dtmDate = "15/04/2015"

The begin date of week: 一周的开始日期:

FirstDayInWeek = dtmDate - Weekday(dtmDate, vbUseSystem) + 1
MsgBox FirstDayInWeek

The end date of Week 周结束日期

LastDayInWeek = dtmDate - Weekday(dtmDate, vbUseSystem) + 7
MsgBox LastDayInWeek

Try this Formula:- 试试这个公式: -

=A1-WEEKDAY(A1,2)+1

Where A1 contains your Input Date. A1包含您的输入日期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM