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

前端 未结 2 1788
小鲜肉
小鲜肉 2021-01-19 00:40

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 be

2条回答
  •  不思量自难忘°
    2021-01-19 01:31

    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
    

提交回复
热议问题