Solved

Access Query - Select two separate dates

Posted on 2009-07-07
5
222 Views
Last Modified: 2012-05-07
I have an Access query that I am using to append to another table.

I want to pull from a date field that would be the last date besides today ie. if there were 10 records accessed yesterday I want those to append to the new table not anything accessed today.

If the last time some recrods were accessed was 2 days ago i want those to append to the new table but not anythign from today.

Is this possible without typing in the date?
0
Comment
Question by:Pdeters
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:shoppedude
ID: 24796933
It is very possible - could you please attach the code that you are presently using?

Thanks!
0
 
LVL 2

Expert Comment

by:Netwoobie
ID: 24797218
You should look into the datediff function. Your query could check if your number of days between your field date and the current date is 1 or 2 and select those into another table.

http://www.techonthenet.com/access/functions/date/datediff.php

0
 

Author Comment

by:Pdeters
ID: 24797268
This is what I am currently using

SELECT Table1.Date_change
FROM Table1
WHERE (((Table1.Date_Change)=[Select Date]));

I am actually selecting the date
0
 
LVL 2

Accepted Solution

by:
shoppedude earned 500 total points
ID: 24797433
This code should work, returning the maximum date from the table where the date is less than the current date.

-Lee
SELECT DISTINCT Table1.Date_Change
FROM Table1
WHERE Table1.Date_Change = (SELECT MAX(A.Date_Change) from Table1 A WHERE A.Date_Change < Date())

Open in new window

0
 

Author Closing Comment

by:Pdeters
ID: 31600734
Thank you
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Union 2 queries to a cte (temp table perhaps) 9 49
T-SQL: Do I need CLUSTERED here? 13 62
awk and Pythagoras? 5 26
Update one table with results from another table in SQL 6 39
In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question