473,467 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Date/Time Calculation

Hello all

I seem to be getting nowhere with this issue - I'm sure it is not that
complex so here goes. I want to create a table with three fields - two
date/time types (Start_Date & Stop_Date) into which I enter dates. The
third field is a calculated value of the days between Start and Stop.
I have tried using Datediff but for some reasson it doesn't like basing the
value of my calculated days field on the result of a query calculated from
withing the same table. Hope this makes sense.

If anybody has a solution I would be grateful - this fast becoming an
obsession! - I am using MS Access 2003 on a Win XP SP2 platform.

Best Regards

Shaun H
May 6 '06 #1
3 1959
DFS
Shaun,

To get the # of days between the dates, you can write a simple update query:

UPDATE table
SET DaysBetween = StopDate - StartDate
WHERE StartDate IS NOT NULL
AND StopDate IS NOT NULL;

If your DaysBetween field is set to Single or Double precision, that query
will return fractions of a day.


Shaun Harwood wrote:
Hello all

I seem to be getting nowhere with this issue - I'm sure it is not that
complex so here goes. I want to create a table with three fields -
two date/time types (Start_Date & Stop_Date) into which I enter
dates. The third field is a calculated value of the days between
Start and Stop.
I have tried using Datediff but for some reasson it doesn't like
basing the value of my calculated days field on the result of a query
calculated from withing the same table. Hope this makes sense.

If anybody has a solution I would be grateful - this fast becoming an
obsession! - I am using MS Access 2003 on a Win XP SP2 platform.

Best Regards

Shaun H

May 6 '06 #2
Thankyou - that does the job perfectly - now is there a way to run the
update query automatically (maybe when you start access) so the field will
update itself - or do I have to run the query each time.

Thanks




May 6 '06 #3
Shaun Harwood wrote in message
<Xn**********************************@207.35.177.1 35> :
Thankyou - that does the job perfectly - now is there a way to run
the update query automatically (maybe when you start access) so the
field will update itself - or do I have to run the query each time.

Thanks




I would recommend that you rethink this strategy. It is considered much
better to calculate values on the fly, when you need them, in stead of
storing the calculated values.

When choosing to "break the rules", as in storing calculated values,
you
expose yourself to the calculated risk of your updates failing,
creating
a situation where your calculated values are out of sync with the
fields
they are supposed to be derived from.

--
Roy-Vidar
May 6 '06 #4

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

Similar topics

9
by: tertius | last post by:
Hi, Is there a more pythonic way to write or do a date difference calculation? I have as input two date fields in the form 'YYYY-MM-DD' TIA Terius
2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
4
by: Manny Chohan | last post by:
Hi Can anyone tell me how i can calculate yesterday date using asp? Thanks manny
1
by: Raghu | last post by:
Hello... I am running into a problem while running a query..can some1 help.. this is the query : ************** SELECT * from Table S where S.dtDate1 BETWEEN...
1
by: mene | last post by:
I have a field that contains date information, and sometimes time information as well. I would like to be able to take that date and do a calculation on it. Here are some examples of what is in...
4
by: qtip | last post by:
I have a simple table the has First Name , Last Name, SSN, Date&Time. I have a report that will show all this information but I would like to put in at calculation to tell the difference between 2...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
1
by: jonny | last post by:
Option Explicit Private mdTarget1 As Date Private mdTarget2 As Date ' called on form load Public Sub SetRecordStartTime() mdTarget1 = DateAdd("n", 60, Time) mdTarget2 = DateAdd("n", 120,...
16
by: W. eWatson | last post by:
Are there some date and time comparison functions that would compare, say, Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd) Is 02/11/07 the same as 02/11/07? Is 14:05:18 after...
11
by: Connie via AccessMonster.com | last post by:
Hi Access Building Friends, I am building a database for a manufacturer who needs to know the projected End_Date of each job. I know the Start_Date and the total days required to do the job. ...
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...
0
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.