473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Exclude Records in Query, DateDiff/DateAdd/DateSerial/ ? HELP

ORINGINAL Post
Thank you in advance. I'm trying to pull all inventory items from December
of the previous year back to 4 years for my accountant. I know this can be
done, but I'm drawing a blank. I've tried;

DateDiff("y",-4,DateIn) and get errors

Please any assistance would be greatly appreciated.

Michael

This was my original post. I'm sorry, I meant to ask, how can pull records
from December of last year, programmatically changing each December to the
previous 4 years, to allow them to be dropped from inventory for taxes?


Cooking the books eh? <g>

DateDiff("yyyy",-4,DateIn)
--
A)bort, R)etry, I)nfluence with large hammer.

This gives me NO records and I know there are records older than 4 years.
I've tried:

DateDiff("yyyy",-4, [DateIn]) and get NO records. This should be records
older than 4 years, should it not? Then I tried:
DateDiff("yyyy",-1,[DateIn]) still NO records. Then I tried;
DateDiff("yyyy",0,[DateIn]) Still NO records in my query.

PLEASE help me. I'm trying to take all inventory from December back four
years out for tax purposes. I would like the query to do it programmatically
each December for the previous four year ago inventory!

So 2004, 4 years back would mean all my 1998 inventory would not show on
this Query. In 2005, I would like all my 1999 inventory to do the same
thing. And so on and so on!

DateIn is the field that shows when the inventory was added, using a short
date mm/dd/yyyy!

Thank you again for all your help.

Michael
Nov 12 '05 #1
1 4961
You've got the wrong syntax for the DateDiff function it should be
DateDiff("yyyy",[1stDate],[2ndDate])
The syntax you're using at the monent is for the DateAdd function.
If you want to find what the date is 4 years previous use a combination of
the DateDiff and the DateAdd
DateDiff("yyyy",DateAdd("yyyy",-4,[DateIn]),[DateIn]).

An easier way to do this in a query would be to filter by using the Year
function on the DateIn. In the query grid select DateIn again and placed it
inside the Year function i.e. Year([ClaimDate]). In the criteria paste the
following
=Year(Date())-5 And <=Year(Date())-1 This will display all records from 1999 to 2003.

Stewart

P.S. When replying to to a message can you please keep it in the same thread
by clicking reply to group instead of starting a new thread. This will all
related messages together.


This gives me NO records and I know there are records older than 4 years.
I've tried:

DateDiff("yyyy",-4, [DateIn]) and get NO records. This should be records
older than 4 years, should it not? Then I tried:
DateDiff("yyyy",-1,[DateIn]) still NO records. Then I tried;
DateDiff("yyyy",0,[DateIn]) Still NO records in my query.

PLEASE help me. I'm trying to take all inventory from December back four
years out for tax purposes. I would like the query to do it programmatically each December for the previous four year ago inventory!

So 2004, 4 years back would mean all my 1998 inventory would not show on
this Query. In 2005, I would like all my 1999 inventory to do the same
thing. And so on and so on!

DateIn is the field that shows when the inventory was added, using a short
date mm/dd/yyyy!

Thank you again for all your help.

Michael

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Vinnie Davidson | last post by:
Hello! I'm trying to get all records from my SQL Server Database with "DeadlineDate" = today (not today - 24 hours). All records has a field called "DeadlineDate", and the date is stored in...
2
by: PMBragg | last post by:
Thank you in advance. I'm trying to pull all inventory items from December of the previous year back to 4 years for my accountant. I know this can be done, but I'm drawing a blank. I've tried; ...
15
by: PMBragg | last post by:
Thank you in advance. I'm trying to pull all inventory items from December of the previous year back to 4 years for my accountant. I know this can be done, but I'm drawing a blank. I've tried; ...
13
by: Sue | last post by:
I'm working on a database that keeps track of employees hired by a general contractor on a project by project basis. These employees are hired to work on a project and are then laid off either at...
10
by: Ken | last post by:
I have a form, that when I open it, it shows all items that are due for inspection in the current month and that is overdue. This is shown in continuous view and it has a column that shows overdue...
11
by: Andy_Khosravi | last post by:
My problem: I'm having trouble with a query taking much too long to run; a query without any criteria evaluating only 650 records takes over 300 seconds to run (over the network. On local drive...
4
by: Drum2001 | last post by:
My question is in reference to the following closed thread. ...
1
by: Jimbo | last post by:
I have a query..if you look at the bottom of the where clause you'll see an "NOT IN" statement that is really hanging up the query..i'm trying to replace with a "NOT EXISTS" but it isnt appearing...
18
by: mlcampeau | last post by:
I have a lengthy query that I am now trying to filter. The query calculates an employee's Anniversary Date in which they are eligible for the next level of Annual Vacation. (i.e. For 1-6 years of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.