Hi,
I have a table that has fields FirstName, Surname and StartDate:
| Ed | Mozley | 14/10/2004 |
| John | Smith | 15/03/2007 |
| Jane | Smith | 02/10/2006 |
I want to run a report that shows all members of staff who joined in the range 1st October of any year to 31st October of any year - eg it should show Ed Mozley and Jane Smith but leave out John Smith.
Now as it is not always going to be October that I am looking at I am building the query dynamically using ASP. This brings certain limitations so the only way I can think of doing this is to do the following:
Find out what day number in the year 1st October is (273)
Find out what day number in the year 31st October is (303)
Select all records where the day number of the start date is between 273 and 303.
So far my query looks like this (but isn't working)
SELECT FirstName, Surname, StartDate
FROM Users
WHERE (DateDiff, "d", DatePart("yyyy", StartDate) & "/01/01") >= 273 AND DateDiff("d", DatePart("yyyy"), StartDate & "/01/01") <= 303
ORDER BY FirstName, ASC
Any help much appreciated!
Thanks very much
Ed
I have a table that has fields FirstName, Surname and StartDate:
| Ed | Mozley | 14/10/2004 |
| John | Smith | 15/03/2007 |
| Jane | Smith | 02/10/2006 |
I want to run a report that shows all members of staff who joined in the range 1st October of any year to 31st October of any year - eg it should show Ed Mozley and Jane Smith but leave out John Smith.
Now as it is not always going to be October that I am looking at I am building the query dynamically using ASP. This brings certain limitations so the only way I can think of doing this is to do the following:
Find out what day number in the year 1st October is (273)
Find out what day number in the year 31st October is (303)
Select all records where the day number of the start date is between 273 and 303.
So far my query looks like this (but isn't working)
SELECT FirstName, Surname, StartDate
FROM Users
WHERE (DateDiff, "d", DatePart("yyyy", StartDate) & "/01/01") >= 273 AND DateDiff("d", DatePart("yyyy"), StartDate & "/01/01") <= 303
ORDER BY FirstName, ASC
Any help much appreciated!
Thanks very much
Ed