473,507 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DateDiff Query

2 New Member
Hi All,

I am currently running a query on a MS Access table, in which I want to be able to compare and total the difference in dates between records. I only have one date field within the table. The table contains the following fields:

Acc. Number
Transaction Date
Detail
Current Balance

Everytime another transaction is completed, the current balance will change. However, a transaction will not be completed every day (it is ad-hoc) and the current balance will remain the same until a transaction is completed.

What I want to do is calculate all current balances for each day. This is to include days that no transactions were recorded, ie, there will be no record for some dates.

I have tried the DateDiff, but this does not seem to work on a single date field (in this case Transaction Date), two date fields are needed (or am I wrong?). Can anyone suggest how I could use the DateDiff argument on a single date field?

Your help is greatly appreciated.

Wheelers.
Aug 11 '08 #1
6 4343
NeoPa
32,557 Recognized Expert Moderator MVP
I can only assume you are referring to determining the difference between dates in sequential records. Otherwise this makes no sense to me at all.

Unfortunately, as SQL doesn't even recognise the concept of sequential records anyway, I think you may be disappointed.

Can you confirm what it is you are saying here?
Aug 11 '08 #2
Wheeler2008
2 New Member
Hi,

Yes, I am speaking about sequential records. I have one date field, and I want to compare one date with the date in the previous record. Is this possible?
Aug 12 '08 #3
NeoPa
32,557 Recognized Expert Moderator MVP
Not exactly, but you can probably put something together using VBA and Recordset processing (See Basic DAO recordset loop using two recordsets).

As I mentioned in my previous post, SQL doesn't even recognise the concept of sequential records. Hence, the idea of processing records in a relative manner is not done for you by Access. You will need to implement your logic manually using VBA code.
Aug 12 '08 #4
Krandor
50 New Member
You are going to have to loop through your records with a recordset.

One of the values will be the prior date and the other will be the current date. From there you can use datediff.
Aug 13 '08 #5
aprpillai
23 New Member
Approximately how many records involved. I can give you an idea not the Code. We use a method to find the Missing Cheque Numbers from the Cheque Payment Voucher Records.

Assume that the Dates involved in your case is between 01-07-2008 and 31-07-2008 maximum 31 dates. But some date may be missing in between. Define an Array in VBA for number of elements i.e End-Date - Begin-Date. Define another parralel array with the same dimension for flaging the missing cases. Generate all the Dates between start-date and end-date and load the array.

The data in table must be sorted on the Date field. Open the table and compare each Array element (say X(K)) with date on the record and flag the second array element for matched cases. If you want to do tabulation of values then you can put that value in the second array. When complete some of the elements in the second array will be empty, which have missing date in the table. You can take a listing of these dates from the first array by checking the status of the second array empty elements.

a.p.r. pillai
** Link Removed **
Aug 15 '08 #6
NeoPa
32,557 Recognized Expert Moderator MVP
I'm afraid that posting of external links as signatures is not allowed in technical threads (Signature Guidelines) so I have removed the link from your post.

Although there is actually a field that contains your official signature, these rules also to apply to any text used in that way.

Administrator.

PS. I should add that I appreciate your posting help in these forums. That's always appreciated of course. I merely draw your attention to the rules you may not have been aware of.
Aug 15 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
7991
by: intl04 | last post by:
I'm trying to set up a query that will include a new field ('Days until completion') whose value is derived from the DateDiff function. I think I have the syntax correct but am not sure. Days...
4
11904
by: Paolo | last post by:
I am having some problem with a Year Function. I have form on which I have 4 field which indicate dates and an additional form which sums those dates: These are the fields: YEARS...
15
7968
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; ...
1
4966
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...
5
6669
by: mcbill20 | last post by:
Hello all. I have a really basic question that I hope someone has a better answer for. I apologize in advance-- I know this is probably a really basic question but I am used to Oracle rathern than...
6
7635
by: kevinjwilson | last post by:
I am trying to get the date difference between two dates but I don't want the function to include weekends in the calculation. Does anyone have an idea on how to make this work?
1
2771
by: Shawn Yates | last post by:
I have query which shows when employees clock in (long time) and clock out(long time). To find the total hours worked in hours and minutes I have another field on my query with the following: ...
9
2808
by: StevoNZ | last post by:
Hi, I am a little stuck with a query I am trying to build. Attemting to calculate the delivery time for a material. I have managed to utilise the DateDiff function, but have some additional...
1
4962
by: Sultan Ali Alhassni | last post by:
I was trying to use the datediff function in the Update query and I added the following on the upate to field : Datediff("d", , where Sentdate: is a date stored in a table called cycle_table ...
4
6090
by: KA NMC | last post by:
I know this is very simple...but the syntax is really screwing me up...Basically what I want to do is have this query check for orders that have been open two hours and more and does not have a...
0
7110
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...
0
7314
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
7482
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...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
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...

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.