?
Solved

Query to get minutes and seconds

Posted on 2009-05-11
1
Medium Priority
?
346 Views
Last Modified: 2013-11-30
Hi All,

I'm trying to write a query which will give me difference between two datetime columns, but the problem is I get answer only in minutes or seconds. I want to have the answer as hh:mm:ss. Below is the query I'm using

For example

Results

X          y       [Total Time] (in mins)
abc     fcd      8

But I want

x          y        [Total Time] (in mm:ss)
abc    fcd        8:24


Thanks
SELECT X,Y,Z, DATEDIFF("n",[Start time], [End time]) as [Total Time]
FROM  [Table  A]

Open in new window

0
Comment
Question by:Samoin
[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
1 Comment
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 750 total points
ID: 24356469
SELECT X,Y,Z, CONVERT(varchar,[End time] -[Start time], 108)  as [Total Time]
FROM  [Table  A]
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

741 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