Display a date

  • Thread starter Thread starter Gert
  • Start date Start date
G

Gert

Hi,

I need to display Friday's date for any given week number in a
parameter query.
The parameter will be the week number.

Thanx!
 
Gert,

Add the following to a standard module:
Public Function GetFridayOfWeek(iWeekNo As Integer) As Date
Dim tmpDate As Date

tmpDate = DateAdd("ww", iWeekNo, DateSerial(Year(Date), 1, 1))
GetFridayOfWeek = tmpDate - (Weekday(tmpDate, vbFriday) - 1)
End Function

Then call it in your SQL, like so:
PARAMETERS WeekNo Short;
SELECT [somefield], GetFridayOfWeek([WeekNo]) As FridayDate
FROM tblMyTable;

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 

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

Back
Top