473,379 Members | 1,520 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,379 software developers and data experts.

Calculating between dates on separate records

Hi,

I have a query that produces an output similar to the sample shown
below. These records are based on certain criteria and a date range
selected from a form. I need to create some kind of calcualtion or
record manipulation to do the following:

I need to subtract dates from one another, for example for ID 1 I want
to find the difference between 24-Jun-04 and 25-Jan-06 for the 2
applications for Person1.

Or, I need to find 730 days (2 years) from the newest date and if the
second date is within this range I need the record displayed.

This becomes even trickier if an ID has more than two applications as I
need to use the difference bewtween dates 2 and 3 and so on.

What I basically need is to be able to calculate between 2 dates where
each is on a different record.

Cheers.

ID Forename1 Surname ApplicationNumber FinalDecisionDate
1 Person1FN Person1SN 216869761 24-Jun-04
1 Person1FN Person1SN -761922672 25-Jan-06
2 Person2FN Person2SN 1109951655 06-Apr-05
2 Person2FN Person2SN 1733776761 22-Jul-04
3 Person3FN Person3SN -1502540739 29-Jun-04
3 Person3FN Person3SN 1103313929 11-Mar-05
4 Person4FN Person4SN -501941607 15-Apr-05
4 Person4FN Person4SN -1230039876 22-Feb-06

Jun 23 '06 #1
2 2069
can you not just use the built in expression "DateDiff()" and reference
each entry using the Forms![Form Name]![Field] ?

Carl wrote:
Hi,

I have a query that produces an output similar to the sample shown
below. These records are based on certain criteria and a date range
selected from a form. I need to create some kind of calcualtion or
record manipulation to do the following:

I need to subtract dates from one another, for example for ID 1 I want
to find the difference between 24-Jun-04 and 25-Jan-06 for the 2
applications for Person1.

Or, I need to find 730 days (2 years) from the newest date and if the
second date is within this range I need the record displayed.

This becomes even trickier if an ID has more than two applications as I
need to use the difference bewtween dates 2 and 3 and so on.

What I basically need is to be able to calculate between 2 dates where
each is on a different record.

Cheers.

ID Forename1 Surname ApplicationNumber FinalDecisionDate
1 Person1FN Person1SN 216869761 24-Jun-04
1 Person1FN Person1SN -761922672 25-Jan-06
2 Person2FN Person2SN 1109951655 06-Apr-05
2 Person2FN Person2SN 1733776761 22-Jul-04
3 Person3FN Person3SN -1502540739 29-Jun-04
3 Person3FN Person3SN 1103313929 11-Mar-05
4 Person4FN Person4SN -501941607 15-Apr-05
4 Person4FN Person4SN -1230039876 22-Feb-06


Jun 23 '06 #2
"Carl" <ca**********@newcastle.gov.uk> wrote in
news:11**********************@y41g2000cwy.googlegr oups.com:
Hi,

I have a query that produces an output similar to the sample
shown below. These records are based on certain criteria and
a date range selected from a form. I need to create some kind
of calcualtion or record manipulation to do the following:

I need to subtract dates from one another, for example for ID
1 I want to find the difference between 24-Jun-04 and
25-Jan-06 for the 2 applications for Person1.

Or, I need to find 730 days (2 years) from the newest date and
if the second date is within this range I need the record
displayed.

This becomes even trickier if an ID has more than two
applications as I need to use the difference bewtween dates 2
and 3 and so on.

What I basically need is to be able to calculate between 2
dates where each is on a different record.

Cheers.

ID Forename1 Surname ApplicationNumber
FinalDecisionDate 1 Person1FN Person1SN 216869761
24-Jun-04 1 Person1FN Person1SN
-761922672 25-Jan-06 2 Person2FN Person2SN
1109951655 06-Apr-05 2 Person2FN Person2SN
1733776761 22-Jul-04 3 Person3FN Person3SN
-1502540739 29-Jun-04 3 Person3FN Person3SN
1103313929 11-Mar-05 4 Person4FN Person4SN
-501941607 15-Apr-05 4 Person4FN Person4SN
-1230039876 22-Feb-06

Ohkayy. What you need to do is create a new query, with two
copies of your existing query or table. Alias the first as A,
the second as B.

then join A to B on personFN and PersonSN, Put the fields from A
down and the applicationNumber, finaldecisiondate from B as
well.

Now create a new field with the expression
DateDiff("d", a.finaldecisiondate, b.finaldecisiondate)
The criteria for that field should be BETWEEN 0 and 730
You also want to put <> B.applicationNumber as the criterion for
A.ApplicationNumber, so you dont compare a date agains itself.

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Jun 23 '06 #3

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

Similar topics

10
by: riki | last post by:
hello, i need to calculate num of days between 2 dates... i get separate parts of dates from html form, then i need to "make" begining and ending date and calculate difference between them......
2
by: BlackFireNova | last post by:
I have an Access 2003 mdb which contains software records. I need to sort on a particular type of software, and then identify and count how many copies there are per each group of that type...
3
by: Wired Hosting News | last post by:
Lets say I have 10 products in 10 different stores and every week I get a report from each store telling me how many items they have left for each of the 10 products. So each week I enter in 100...
5
by: Wired Hosting News | last post by:
I tried to be breif and give a scenario so as not to be overlooked because it was soooo long. Let me give you real world. I am a manufacturer of goods and produce 11 items that are distributed...
8
by: King | last post by:
Hi I have following MS Acess query Here is the query ID Name Prgm ID Client ID Date Start Time End Time Minutes C4 Trisha TIP DEK0703 7 /7 /2006...
13
by: drago | last post by:
Hi guys, good to be here... I am struggling to calculated days in invoice system...Ok...The dates fields are of two kinds...One is the invoice start date and end date... The other one is the contract...
2
by: mtchampi | last post by:
Hello all, I have a limited SQL background, and I am responsible for creating a monthly report that displays separate tables for the following: 1. Calculate individual monthly totals of files...
2
by: ncsthbell | last post by:
I am having problems getting the end date to calculate correctly. I start with Quarter '03/02', (YY/QTR), for this it means it is for the 2nd qtr of 2003. My goal is to get the begin & end dates...
3
rcollins
by: rcollins | last post by:
I ahve a database that I put together to keep track of the office supplies. We input what has been purchased and what goes out. When I run a report, usually it is just for a month, but I have a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
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...

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.