Solved

Query to get minutes and seconds

Posted on 2009-05-11
1
327 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

856 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