Re: Difference between two dates and times
From: John Vinson (jvinson_at_STOP_SPAM.WysardOfInfo.com)
Date: 10/20/04
- Next message: John Vinson: "Re: How do I write a conditional expression in access?"
- Previous message: MJ: "Re: bad query?"
- In reply to: quartz: "Difference between two dates and times"
- Next in thread: quartz: "Re: Difference between two dates and times"
- Reply: quartz: "Re: Difference between two dates and times"
- Reply: Jamie Collins: "Re: Difference between two dates and times"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 20 Oct 2004 11:55:47 -0600
On Wed, 20 Oct 2004 07:19:04 -0700, quartz
<quartz@discussions.microsoft.com> wrote:
>I have two columns in a table. One is START_TIME the other is END_TIME and
>they are both TIMESTAMP data types formatted as "MM-DD-YYYY HH:MM:SS AM/PM".
Are these SQL Server tables? Access (JET) tables have a Date/Time
datatype but do not have a Timestamp.
>In a third column (ELAPSED_TIME) I want to calculate the difference between
>the first two columns (i.e. END_TIME - START_TIME) and show the difference
>with a picture of: DD HH:MM:SS or DD-HH:MM:SS (example result: 00 00:01:34 or
>00-00:02:18).
>
>My calculation is running in the current Access DB project and will update
>the table with the calculation using SQL. PLEASE NOTE: Sometimes this process
>runs across two days, e.g. may start at 11:40 pm and may finish at 12:10 am.
Take a look at the DateDiff() function in the VBA help. I believe it
will work with TIMESTAMP values as well as Date/Time values but I'm
not absolutely certain! It will give you a difference in your choice
of units (from seconds to years) as an integer.
I would strongly recommend that you NOT store the ELAPSED_TIME in any
table field; it's redundant and can be calculated whenever it's
needed.
John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
- Next message: John Vinson: "Re: How do I write a conditional expression in access?"
- Previous message: MJ: "Re: bad query?"
- In reply to: quartz: "Difference between two dates and times"
- Next in thread: quartz: "Re: Difference between two dates and times"
- Reply: quartz: "Re: Difference between two dates and times"
- Reply: Jamie Collins: "Re: Difference between two dates and times"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|