Finding the date of the beginning and end of week

# Thread: Finding the date of the beginning and end of week

1. Join Date
Dec 1969
Posts
32

## Finding the date of the beginning and end of week

Been sort of banging my head on this one - if I supplied a date (any date) I want to then be able to return the date of that Sunday and that Saturday that the provided date falls between. I know it&#039;s probably a combination of Weekday() and DateDiff(), right?

2. Senior Member
Join Date
Dec 1969
Posts
155

## RE: Finding the date of the beginning and end of w

WeekBeginning = Weekday(Date)<BR>WeekBeginning = WeekBeginning - 1<BR>WeekBeginning = DateAdd("d", -WeekBeginning, Date)<BR><BR>WeekEnding = Weekday(Date)<BR>WeekEnding = 7 - WeekEnding<BR>WeekEnding = DateAdd("d", WeekEnding, Date)<BR><BR>Crude, but works!

3. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## hmmm

wont 7 give you the next SUNDAY<BR><BR>you will have to make that a 6...i think<BR><BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
155

## RE: hmmm

It depends on the systems "firstdayoftheweek" property, the default is Sunday but you can specify a different one in the weekday function.<BR><BR>More info from: <BR><BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctWeekday.asp

5. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## if you do that

then your first calculation will be wrong.....so you will have to do that AFTER you get the first day of the week<BR><BR><BR>the easy way will be to say 6 - whatever<BR><BR><BR>

6. Join Date
Dec 1969
Posts
32

## RE: Finding the date of the beginning and end of w

This works well, thanks.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•