Solved

subtract two datetime fields (start and finish) with the result being datetime

Posted on 2013-05-21
3
423 Views
Last Modified: 2013-05-22
what datatype hours:minutes is the subtraction between two datetime fields

do not just want to calculate difference

because I want to store this value in a field
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Accepted Solution

by:
kavi112 earned 250 total points
ID: 39186633
Use DATEDIFF to find datetime differences. and use DATEPART to control the format of the result.
ex:
SELECT DATEDIFF (datepart, '2010-01-22 15:29:55.090', '2010-01-22 15:30:09.153')
Substitute "datepart" based on DATEDIFF on MSDN
0
 
LVL 49

Assisted Solution

by:PortletPaul
PortletPaul earned 250 total points
ID: 39186662
datediff is the function for the wanted subtraction, but you must decide what time units you will store, e.g.

set somefield = datediff(second,start_date,end_date)

set somefield = datediff(minute,start_date,end_date)

(I generally see seconds used in such situations.)

You might consider using a 'calculated column'  if this suits the purpose.
0
 

Author Closing Comment

by:rgb192
ID: 39186757
thanks
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question