Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

excel

vba

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).

thanks

like image 787
Benss Avatar asked May 04 '15 09:05

Benss


People also ask

How do you find the week start date and end date from a given week number?

Select a blank cell you will return the week number, enter this formula: =WEEKNUM(B1,1), and press the Enter key. See screenshot: Notes: (1) In above formula, B1 contains the date that you want to use.


1 Answers

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
like image 70
daniele3004 Avatar answered Sep 20 '22 18:09

daniele3004