Solved

Query to get minutes and seconds

Posted on 2009-05-11
1
299 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
1 Comment
 
LVL 75

Accepted Solution

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

707 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

13 Experts available now in Live!

Get 1:1 Help Now