473,778 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ApplicationNumb er FinalDecisionDa te
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 2093
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 ApplicationNumb er FinalDecisionDa te
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**********@n ewcastle.gov.uk > wrote in
news:11******** **************@ y41g2000cwy.goo glegroups.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 ApplicationNumb er
FinalDecisionDa te 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 applicationNumb er, finaldecisionda te from B as
well.

Now create a new field with the expression
DateDiff("d", a.finaldecision date, b.finaldecision date)
The criteria for that field should be BETWEEN 0 and 730
You also want to put <> B.applicationNu mber as the criterion for
A.ApplicationNu mber, 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
6642
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... something like this, in sybase: DAYS(YMD(?YEAR?,?MONTH?,?DAY?), YMD(?YEAR1?,?MONTH1?,?DAY1?)) thnx
2
2304
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 purchased on the same date. I have no trouble doing a query to extract the type (say MS Excel 2002, for example). The trouble is, there could be 50 copies purchased on date "x", 80 copies purchased on date "y", and 250 copies purchased on date "z",...
3
2202
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 records with a store number, item number, on hand qty, and date of report into my sales data table. My tables primary is a combo of store# & Item number & Date After 10 week of this I have 1000 record total with ten unique dates.
5
3532
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 to 1800 stores of a national home improvement chain store. Every week I electronicaly receive an excel spreadsheet "inventory report" with 19,800 rows or records, which I import into my tblSalesData table. The table now has 10 weeks of data or...
8
4012
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 10:00:00 AM 12:00:00 PM 120
13
2421
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 start date and end date...I have to calculate days of charging according to the dates involved... Suppose INVOICE start date: 01-01-07; INVOICE end date: 31-01-07 Conditions are: 1. IF the contract start date is BEFORE(<=) the invoice...
2
1876
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 processed (created) that month 2. Accumulating totals per month, (eg. Jan 200 files, Feb 300 files, so Feb would now read as 500 files) 3. Take a constant number, say 10,000 records, subtract the year to date result(from the accummulating totals)...
2
5857
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 for each 'month' in the quarter, hence, I want to calculate the begin & end of the month dates for April, May & June 2003 : so my starting point is: firstMonthBegin = vcBegMM & "/" & vcBegDD & "/" & vcBegYY firstMonthEnd = vcEndMM &...
3
2091
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 calculation issue with this. If I run the report for the whale time we have used this database, the units on hand is correct. When I run it for specific dates, it only calculates the on hand for these times, throwing off the total of on hand supplies. I...
0
9632
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10136
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.