Hello everyone,
I was recently tasked to convert some of the functions employees use Excel for into Access. One of these functions is seeing which invoices are due to be paid this month. Surely this is simple I thought, and so it would be - if I had a field with a duedate in it. However I am using the sum of two fields as my date and thus, I feel, I have a problem. It's the end of the day and I'm knackered, can anyone spot my Query error?
The below code is one of the many different ways I've tried to skin this cat...
(There are plenty of records with both [TermsDays] AND [TermsDate] NULL.)
In Query; Datatype mismatch in this case. I assume with the DateAdd? - SELECT tblPurchaseOrderDetail.*, tblPurchaseOrderDetail.TermsDays, tblPurchaseOrderDetail.TermsDate
-
FROM tblPurchaseOrdersHeader INNER JOIN tblPurchaseOrderDetail ON tblPurchaseOrdersHeader.OrderNumber = tblPurchaseOrderDetail.OrderNumber
-
WHERE (((tblPurchaseOrderDetail.TermsDate) Is Not Null) AND ((DateAdd("d",[TermsDays],[TermsDate]))>=DateSerial(Year(Now()),Month(Now()),1) And (DateAdd("d",[TermsDays],[TermsDate]))<DateSerial(Year(Now()),Month(Now()),1)));
-
Any help would be greatly appreciated.
John
I would probably use: -
SELECT tblPurchaseOrderDetail.*, tblPurchaseOrderDetail.TermsDays, tblPurchaseOrderDetail.TermsDate
-
FROM tblPurchaseOrdersHeader INNER JOIN tblPurchaseOrderDetail ON tblPurchaseOrdersHeader.OrderNumber = tblPurchaseOrderDetail.OrderNumber
-
WHERE tblPurchaseOrderDetail.TermsDate Is Not Null
-
AND tblPurchaseOrderDetail.TermsDays Is Not Null
-
AND [TermsDate] + [TermsDays] between DateSerial(Year(Date()),Month(Date()),1) And DateSerial(Year(Date()),Month(Date())+1,0)));
-
Adding days can be done using simply a "+", being faster as the DateAdd function. Using the 0 in the Dateserial will give the last day of a month.
Using "Between" is faster as it's just one comparison instead of two when using >= and <=.
Guess you would also need a report showing records without a Date and/or term, as they will be skipped...
Nic;o)
3 4625
I would probably use: -
SELECT tblPurchaseOrderDetail.*, tblPurchaseOrderDetail.TermsDays, tblPurchaseOrderDetail.TermsDate
-
FROM tblPurchaseOrdersHeader INNER JOIN tblPurchaseOrderDetail ON tblPurchaseOrdersHeader.OrderNumber = tblPurchaseOrderDetail.OrderNumber
-
WHERE tblPurchaseOrderDetail.TermsDate Is Not Null
-
AND tblPurchaseOrderDetail.TermsDays Is Not Null
-
AND [TermsDate] + [TermsDays] between DateSerial(Year(Date()),Month(Date()),1) And DateSerial(Year(Date()),Month(Date())+1,0)));
-
Adding days can be done using simply a "+", being faster as the DateAdd function. Using the 0 in the Dateserial will give the last day of a month.
Using "Between" is faster as it's just one comparison instead of two when using >= and <=.
Guess you would also need a report showing records without a Date and/or term, as they will be skipped...
Nic;o)
Thats bang on, thanks very much Nico! Don't know how I got stuck on that, but everythings simple in retrospect right? I'm grateful for the quick concise answer!
John
Getting things simple is the hardest part <LOL>
Glad I could help and success with your application !
Nic;o)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: bissatch |
last post by:
Hi,
How do I compare two date stored within a database with datatype
'date'?
The dates are stored within a PostgreSQL database table in the format
"Y-m-d".
Cheers
|
by: Fons Dijkstra |
last post by:
Hello,
I'm using the mx.ODBC.Windows package in order to read/write a MSAccess
database. Everything works fine apart from the DATE format handling. I'm
using the default "datetimeformat" (i.e....
|
by: PMBragg |
last post by:
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...
|
by: Paul# |
last post by:
how do i query for a record between two dates using Access 2000?
right now Im doing this:
SELECT *
FROM tblDateTotal
WHERE .<>0
And .
Between 1/1/1901
And 10/10/2050;
|
by: Bill R via AccessMonster.com |
last post by:
I have a query:
SELECT tblCalendar.CalendarDay AS LastSunday
FROM tblCalendar
WHERE (((tblCalendar.CalendarDay)>=(Now()-7) And (tblCalendar.CalendarDay)...
|
by: Good Man |
last post by:
Hi there
I have a list of jobs scheduled in a MySQL table, with start dates and
end dates, like so:
SchedID | JobID | StartDate | EndDate |...
|
by: ode |
last post by:
I am an infrequent user and my version is Access 2000. I have a list of 122k lines which consits of 3 fields/data points;a product code, a date, and a price code. I want to run a query to select...
|
by: ringer |
last post by:
On a form I have a combo where a month is entered. It shows the month names
in column one, but it is bound to column two where each month's corresponding
number is, ie Jan=1, Feb=2, etc. So...
|
by: samvb |
last post by:
Hi,
I have this query:
SELECT finishtime, bonas, dateadd('s',bonas,finishtime) AS fmore
FROM scores;
It works great but I need to order the result by fmore. It generates errors. Is...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |