Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query by day of the week

Status
Not open for further replies.

Vandelay

Programmer
Jun 22, 2003
95
0
0
US
How do I do a query that would return every 'Tuesday' or every Nth day of the week?
 
There is a function that you can use to enter a date and it will return the day of the week example:

Dim MyDate, MyWeekDay
MyDate = #February 12, 1969# ' Assign a date.
MyWeekDay = Weekday(MyDate) ' MyWeekDay contains 4 because
' MyDate represents a Wednesday.

Here is the syntax:
WEEKDAY(serial_number,return_type)

Serial_number is a number that represents a date or text in date format, such as "4-1-1999" or "31-Oct-2000".

Return_type is a number: for Sunday = 1 through Saturday = 7, use 1; for Monday = 1 through Sunday = 7, use 2; for Monday = 0 through Sunday = 1, use 3.


Just key your IF statement using this function.


RUN FunnySignatureMessage
 
Where do I do this at? In the query window?
 
You can. Here is a SQL code example:


SELECT *
FROM [yourTable]
WHERE weekday([dateField] = 3



RUN FunnySignatureMessage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top