By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,377 Members | 3,052 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,377 IT Pros & Developers. It's quick & easy.

Week

P: n/a
I have a work assignment that

gives me a date

and I want to find all other dates in that week.

Any ideas?
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
scorpion53061 wrote:
I have a work assignment that

gives me a date

and I want to find all other dates in that week.

Any ideas?

Well, if you know the date, there is the WeekDay() function to tell you
what day of the week it is. And it depends on what day of the week you
want to start your week from.

From there you can use the DateAdd to determine the dates using For/Next.

Nov 12 '05 #2

P: n/a
On Fri, 30 Apr 2004 23:40:27 -0500, scorpion53061 wrote:
I have a work assignment that

gives me a date

and I want to find all other dates in that week.

Any ideas?


Sub FindDate()
Dim dteDate As Date
Dim intY As Integer
Dim intX As Integer
dteDate = InputBox("Enter the Date")
intX = Weekday(dteDate) - 1

dteDate = dteDate - intX
For intY = 1 To 7
Debug.Print dteDate
dteDate = dteDate + 1
Next intY

End Sub

Your next work assignment is to explain what is happening here. :-)
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 12 '05 #3

P: n/a

"scorpion53061" <sc************@nospamhereeveryahoo.com> wrote in message
news:10*************@corp.supernews.com...
I have a work assignment that

gives me a date

and I want to find all other dates in that week.


Here are two functions that may be of help, given a date, to return the
first day of the week and the last day of the week:

Function FDOW(pdatADay As Date) As Date
If Weekday(pdatADay) = 1 Then
FDOW = pdatADay
Else
FDOW = DateAdd("d", pdatADay, -Weekday(pdatADay) + 1)
End If
End Function

Function LDOW(pdatADay As Date) As Date
If Weekday(pdatADay) = 7 Then
LDOW = pdatADay
Else
LDOW = DateAdd("d", pdatADay, 7 - Weekday(pdatADay))
End If
End Function
Nov 12 '05 #4

P: n/a
no problem.

It is a time card app that my predecessor wrote in access but he used a text
instead of 'date' field column type. (Why!!!!)

Payroll wanted to see the payroll divided up by week.
(Sun - Sat)

I am having some problems with these functions but thank you guys for
getting me started. If you have any more ideas please post....

"fredg" <fg******@example.invalid> wrote in message
news:tx****************************@40tude.net...
On Fri, 30 Apr 2004 23:40:27 -0500, scorpion53061 wrote:
I have a work assignment that

gives me a date

and I want to find all other dates in that week.

Any ideas?


Sub FindDate()
Dim dteDate As Date
Dim intY As Integer
Dim intX As Integer
dteDate = InputBox("Enter the Date")
intX = Weekday(dteDate) - 1

dteDate = dteDate - intX
For intY = 1 To 7
Debug.Print dteDate
dteDate = dteDate + 1
Next intY

End Sub

Your next work assignment is to explain what is happening here. :-)
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.