A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Calculate difference between to dates



 
 
Thread Tools Display Modes
  #1  
Old March 19th, 2008, 12:54 PM posted to microsoft.public.access.gettingstarted
Clemens
external usenet poster
 
Posts: 28
Default Calculate difference between to dates

I have a table with 2 date fields: [Open Date] and [Close time].
Both field have the following format: dd-mm-yyyy hh:nn.

How can I calculate the difference in days between these 2 fields and how
can I display this on a report where I want to have 4 colums like:
recordnummer - Open date - Close time - difference (or time 'record
open')

Can any one help me?
  #2  
Old March 19th, 2008, 01:04 PM posted to microsoft.public.access.gettingstarted
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Calculate difference between to dates

The difference should not be stored in the table. (Calculated values rarely,
if ever, should be stored)

Instead, create a query based on the table, and add a computed field to the
query. Use the query wherever you would otherwise have used the table.

To add the computed field in the graphical query builder, type the following
into an empty cell on the Field: row:

Difference: DateDiff("n", [Open Date], [Close Time])

That will return the difference between the two times in minutes. (using "s"
instead of "n" will return the difference in seconds) It is not possible to
return the difference in, say, hh:nn format. To do that, you'd need create a
function to convert from total minutes (or total seconds) to hh:nn (or
hh:nn:ss) format.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Clemens" wrote in message
...
I have a table with 2 date fields: [Open Date] and [Close time].
Both field have the following format: dd-mm-yyyy hh:nn.

How can I calculate the difference in days between these 2 fields and how
can I display this on a report where I want to have 4 colums like:
recordnummer - Open date - Close time - difference (or time 'record
open')

Can any one help me?



  #3  
Old April 17th, 2008, 09:16 PM posted to microsoft.public.access.gettingstarted
Margaret Bartley[_3_]
external usenet poster
 
Posts: 30
Default Calculate difference between to dates


"Clemens" wrote in message
...
I have a table with 2 date fields: [Open Date] and [Close time].
Both field have the following format: dd-mm-yyyy hh:nn.

How can I calculate the difference in days between these 2 fields and how
can I display this on a report where I want to have 4 colums like:
recordnummer - Open date - Close time - difference (or time 'record
open')


If you look at the DateDiff function documentation in the Help system, you
can see your various options.

If you want to calculate days, it would be DateDiff("d",OpenDate,CloseTime)

It will ignore the hours and minutes.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.