How to Calc Last Friday of each week!

# Thread: How to Calc Last Friday of each week!

1. Junior Member
Join Date
Dec 1969
Posts
9

## How to Calc Last Friday of each week!

Hi,<BR> How can we calculte the date for the last friday for each week.<BR>Thanks<BR>Sai

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## A week only has one Friday

Do you mean you want the date for Friday of the current week?<BR><BR>&#060;%<BR>today = Date( )<BR>lastSaturday = today - Weekday( today )<BR>fridayThisWeek = lastSaturday + 6<BR>%&#062;<BR>or, a little shorter:<BR>&#060;%<BR>fridayThisWeek = Date() - Weekday(Date()) + 6<BR>%&#062;<BR><BR>****************************<B R><BR>Or did you mis-type and mean you wanted the last Friday of the current *MONTH*?<BR><BR>That&#039;s a little harder...hmmm....<BR><BR>&#060;%<BR>today = Date()<BR>&#039; see DateSerial docs for why this works:<BR>lastDayOfMonth = DateSerial( Year(today), Month(today)+1, 0 ) <BR><BR>If Weekday( lastDayOfMonth ) &#062;= 6 Then<BR>&nbsp; &nbsp; &#039; if last day of month is Friday or Saturday...<BR>&nbsp; &nbsp; lastFriday = lastDayOfMonth - Weekday(lastDayOfMonth) + 6<BR>Else<BR>&nbsp; &nbsp; &#039; if this is Sunday through Thursday, we have to back up <BR>&nbsp; &nbsp; &#039; a week before finding friday...<BR>&nbsp; &nbsp; backOneWeek = lastDayOfMonth - 7<BR>&nbsp; &nbsp; lastFriday = backOneWeek - Weekday(backOneWeek) + 6<BR>End If<BR>%&#062;<BR><BR>or, again simplifying a bit:<BR><BR>&#060;%<BR>temp = DateSerial( Year(Date()), Month(Date())+1, 0 ) <BR>If Weekday( lastDayOfMonth ) &#060; 6 Then temp = temp - 7<BR>lastFriday = temp - Weekday(temp) + 6<BR>%&#062;<BR><BR>Try those. See if they work.<BR><BR>

3. Junior Member
Join Date
Dec 1969
Posts
9

## RE: A week only has one Friday

Yup, I am sorry for mistyping, I meant the former i.e the friday of this week - it was supposed to be the last working day and not last friday. I apologize and yeah thanks. i had written a kranky soln with a stored procedure, now i will replace that with the one line u provided.<BR><BR>Thanks for the help!

#### Posting Permissions

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