Solved

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

Posted on 2013-05-21
3
416 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
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 48

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now