Getting Entire Week's Dates for a Date

Results 1 to 2 of 2

Thread: Getting Entire Week's Dates for a Date

  1. #1
    Join Date
    Dec 1969

    Default Getting Entire Week's Dates for a Date

    &nbsp;<BR><BR>I was wondering if anyone had written a function .NET which would take a date as an argument and return dates for that entire week starting sunday ending saturday.<BR><BR>For Example if I pass &#039;05/21/2003&#039; it should return the following<BR><BR>05/18/2003 - Sun<BR>05/19/2003 - Mon<BR>05/20/2003 - Tue<BR>05/21/2003 - Wed<BR>05/22/2003 - Thu<BR>05/23/2003 - Fri<BR>05/24/2003 - Sat<BR><BR><BR>Thanks for your help!

  2. #2
    Join Date
    Dec 1969

    Default Classic ASP example

    But easily convertible...this returns the Sunday date from a given date. Then just run a for loop with the datadd function to get the remaining 6 days.<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