Return the First Date (Sunday) and Last Date (Saturday) EASY Help!

G

Guest

Hello All,

Can someone give me the formula to return the first date
of the week and last date of the week from a given date.
Example:

MyDate="11/21/2003"
Formula return = "11/16/2003 - 11/22/2003"

thnx.
 
S

StCyrM

Good afternoon

These two functions will give you your required dates.

Maurice



Function StartOfWeek(D As Variant, Optional FirstWeekday As Integer) As Variant
'
' Returns the date representing the first day of the current week.
'
' Arguments:
' D = Date
' FirstWeekday = (Optional argument) Integer that represents the first
' day of the week (e.g., 1=Sun..7=Sat).
'
If IsMissing(FirstWeekday) Then 'Sunday is the assumed first day of week.
StartOfWeek = D - WeekDay(D) + 1
Else
StartOfWeek = D - WeekDay(D, FirstWeekday) + 1
End If
End Function

==========================
Function EndOfWeek(D As Variant, Optional FirstWeekday As Integer) As Variant
'
' Returns the date representing the last day of the current week.
'
' Arguments:
' D = Date
' FirstWeekday = (Optional argument) Integer that represents the first
' day of the week (e.g., 1=Sun..7=Sat).
'
If IsMissing(FirstWeekday) Then 'Sunday is the assumed first day of week.
EndOfWeek = D - WeekDay(D) + 7
Else
EndOfWeek = D - WeekDay(D, FirstWeekday) + 7
End If
End Function






Can someone give me the formula to return the first date
of the week and last date of the week from a given date.
==========================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top