date based on week

# Thread: date based on week

1. Junior Member
Join Date
Dec 1969
Posts
2

## date based on week

Hi.<BR><BR>I am looking around to find som help on how I can get the date based on the numer of the week.<BR>What I want is the startdate and the enddate for that week.<BR><BR>Has anyone done something like this here?<BR><BR>Regards, Truls Clark

2. Senior Member
Join Date
Dec 1969
Posts
497

## not to hard...

but what language are you working with??<BR><BR>sponge

3. Junior Member
Join Date
Dec 1969
Posts
2

## RE: not to hard...

I am working in asp.<BR>I am using this to get the weeknumber:<BR> WeekNumber = DatePart("ww", Date, 1, vbFirstFourDays)<BR><BR>and now I need to get the startdate and enddate for this week, and X following weeks.<BR><BR>Regards.

4. Senior Member
Join Date
Dec 1969
Posts
16,931

## Why not....

Why not get the weekday of the current date (using DatePart again), and then work out the date of the monday...<BR><BR>You can then easily add 6 days on for the end-date, and a further 1 day on for the start date of the next week...<BR><BR>Craig.

5. Senior Member
Join Date
Dec 1969
Posts
2,809

## Wish this were a FAQ...

I&#039;ve answered this question a bunch of times. I submitted it to be a FAQ but never got answered. Here&#039;s a recursive function I wrote that takes a date and returns the sunday date for the week. If you need the sat date as well, just take sunday&#039;s and add 6. <BR><BR>&#039;Function returns Sunday day of the week<BR>Function ReturnSunday(dteDate)<BR> Dim varDayofWeek<BR> varDayofWeek = WeekDay(dteDate)<BR> <BR> &#039;Check to see if the day is already sunday. If not, find sunday. Use recursion.<BR> If varDayofWeek = 1 Then<BR> ReturnSunday = dteDate<BR> Else<BR> ReturnSunday = ReturnSunday(dateadd("d",-1,dteDate))<BR> End If<BR>End Function

#### Posting Permissions

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