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!

Displaying dates for a certain day

Status
Not open for further replies.

mans

Programmer
Mar 18, 2000
136
0
0
AU
Hello,

I have a simple table (Access2000), one column with the date (table1.date) and another with a name (table1.name). Can some one please post the SQL statement required to display all of the dates and names that fall on a Thursday.

Thank You
 
mans
To get all dates that fall on a Thursday, put the following criteria in your date column...
Weekday([YourDateField])=4

By the way, it is better not to use Date and Name as the names for field in a table. They are reserved words in Access. Rename your Date field in table1 to something such as MyDate or whatever you like.

For example, Date() is used to derive the current date. So if your field is named Date this just runs into all kinds of trouble.

Tom
 
How are ya mans . . . . .
Code:
[blue]SELECT Table1.Date, Table1.Name
FROM Table1
WHERE ((Weekday([Date])=5));[/blue]
Also, in table design view, add the following in the [blue]Format Property[/blue] for Date:
Code:
[blue]ddd mmm d\,yyyy[/blue]
The date will display as Tue Jan 4,2004 . . . . .


cal.gif
See Ya! . . . . . .
 
mans
The AceMan1 is absolutely correct in using
Weekday([DateField])=5 to return Thursday.

I surely didn't intend to mislead. Somehow I was looking at the wrong dates and just went by them.

Thanks, AceMan1, for the correction!

Tom
 
Thank you very much Tom and AceMan1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top