Show records with dates 30 days old

G

Guest

I need to know how to build an expression or use a date/time function in a
query to show records with a date that is more than 30 days old.
 
J

James

Hi

You can put the <(Date()-30)) in the criteria of the date field in
quetion or the following in SQL view replacing the tablename and
fieldname as appropriate WHERE (((TableName.DateField)<(Date()-30)))

Hope this helps
James
 
G

Guest

Thanks, James. It was just what I needed. I do have another question,
however. How do I limit the records displayed to the current year?
 
G

Guest

Thanks, James. It was just what I needed. I do have another question,
however. How do I limit the results to show just the current year's records?
 
S

Smartin

Lewis said:
Thanks, James. It was just what I needed. I do have another question,
however. How do I limit the results to show just the current year's records?

The combination of over 30 days old and in the same calendar year will
always be false in January (well, except maybe the 31st) and of
questionable value in the first few months of any year.

Did you really mean to check the last 365 days? If so, you could modify
Lewis's solution to look like
Between (Date()-30)) And (Date()-365))

If you really wanted to do as you said,

Add to your WHERE clause:
AND YEAR(TableName.DateField) = YEAR(DATE)

The the query builder this might look like (in a new column):
Field: YEAR(TableName.DateField)
Show: no
Criteria: = YEAR(DATE)
 
S

Smartin

Lewis said:
Thanks, James. It was just what I needed. I do have another question,
however. How do I limit the results to show just the current year's records?

The combination of over 30 days old and in the same calendar year will
always be false in January (well, except maybe the 31st) and of
questionable value in the first few months of any year.

Did you really mean to check the last 365 days? If so, you could modify
James's solution to look like
Between (Date()-30)) And (Date()-365))

If you really wanted to do as you said,

Add to your WHERE clause:
AND YEAR(TableName.DateField) = YEAR(DATE)

The the query builder this might look like (in a new column):
Field: YEAR(TableName.DateField)
Show: no
Criteria: = YEAR(DATE)





[message with incorrect attribution was canceled -- apologies to James
for any confusion]
 
G

Guest

Thanks for the solution. The 365 days tip is want I really needed.

Smartin said:
Lewis said:
Thanks, James. It was just what I needed. I do have another question,
however. How do I limit the results to show just the current year's records?

The combination of over 30 days old and in the same calendar year will
always be false in January (well, except maybe the 31st) and of
questionable value in the first few months of any year.

Did you really mean to check the last 365 days? If so, you could modify
James's solution to look like
Between (Date()-30)) And (Date()-365))

If you really wanted to do as you said,

Add to your WHERE clause:
AND YEAR(TableName.DateField) = YEAR(DATE)

The the query builder this might look like (in a new column):
Field: YEAR(TableName.DateField)
Show: no
Criteria: = YEAR(DATE)





[message with incorrect attribution was canceled -- apologies to James
for any confusion]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Excel Colour code dates 1
Show 0-30 days from Today 4
display records from a query 1
Filtering records by date 2
Greater than 30 days old 3
Past Due 30 days by Now 3
Query on dates 6
most recent dates of duplicate records 4

Top