NOTE the change in the WHERE clause.
SELECT change_log.Date, change_log.Time, change_log.Location,
change_log.Description, change_log.followup, change_log.field,
change_log.central, change_log.Temp, change_log.Arcived, change_log.Freeway,
change_log.Freeway_time, change_log.Completed, change_log.[Tech/person]
FROM change_log
WHERE (((change_log.Date)>=Date()-5 And (change_log.Date)<=Date()))
ORDER BY change_log.Date DESC;
IF this doesn't work, then please open your Change_log table in design view
and make sure the changelog.Date field is a DateTime field. If it isn't
then you can try modifying the query or fixing the data type. Modify the
query by forcing the date field to become a datetime field using the
following where clause.
SELECT change_log.Date, change_log.Time, change_log.Location,
change_log.Description, change_log.followup, change_log.field,
change_log.central, change_log.Temp, change_log.Arcived, change_log.Freeway,
change_log.Freeway_time, change_log.Completed, change_log.[Tech/person]
FROM change_log
WHERE (((DateValue(change_log.Date))>=Date()-5 And
DateValue((change_log.Date))<=Date()))
ORDER BY change_log.Date DESC;
Dax said:
Still having the same problem
Here is the SQL View
SELECT change_log.Date, change_log.Time, change_log.Location,
change_log.Description, change_log.followup, change_log.field,
change_log.central, change_log.Temp, change_log.Arcived,
change_log.Freeway,
change_log.Freeway_time, change_log.Completed, change_log.[Tech/person]
FROM change_log
WHERE (((change_log.Date)>=Now()-"5" And (change_log.Date)<=Now()))
ORDER BY change_log.Date DESC;
John Spencer said:
DROP the quotes around the 5. Your criteria should be
=Date()-5 And <=Date()
Which is the same as
Between Date()-5 and Date()
Which is what Rick B posted.
If that is not working then it is probable that your date field is not a
date field but is a text field containing a string that looks like a
date.
Try posting the SQL text view of your query for further help.
That still gives me all of the Dec, Nov, & Oct.
The field that I am using to sort on is one that is populated by Date()
And therefore does not have a leading 0 on the month or the day so it
formats m/d/yyyy
So the problem that I am having is that the query brings up all dates
that
have a 1 in the month [example Jan(1), Oct(10), Nov(11), Dec(12)]
So I am still having the same problem.
Oh and I copied the wrong criteria
Then one that I have is ">=Date()-"5" And <=Date()"
Again any way around this problem would be appreciated.
Thank you to Rick B for trying
:
Oops - I guess you may have records with a date later than today? If
so
then use:
Between Date()-5 and Date()
--
Rick B
I have a shift log that all of my staff is using, and I need to show
what
has
been entered in the last 5 days up to the current day.
I currently have Query that shows this, but when the day or the
month
is a
single digit the then it shows data from much farther back.
For instance it is the 1st of Feb, so the last five days are Jan 27,
28,
29,
30 & 31.
My query shows all of December (12) all of October (10) all of
November
(11)
as well. the criteria I have in my query is
">=Date()-"1" And <=Date()"
Any help would be apreceated.