Solved

Datetime Start End - minutes

Posted on 2011-02-26
1
232 Views
Last Modified: 2012-05-11
I have 2 datetime columns in a table - StartTime and Endtime. I would like to find the difference in minutes so that it will round up, i.e. 75 s would be 2 min. How is best to do that?
0
Comment
Question by:johnkainn
[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 23

Accepted Solution

by:
Rajkumar Gs earned 125 total points
ID: 34986813
CEILING() will help you do with DATEDIFF

DECLARE @StartTime DATETIME, @EndTime DATETIME
SET @StartTime = '2011-02-26 16:26:26.623'
SET @EndTime = '2011-02-26 16:27:40.623'
SELECT CAST(DATEDIFF(s, @StartTime, @EndTime) AS DECIMAL(18,2)) AS ActualSeconds
SELECT CEILING(CAST(DATEDIFF(s, @StartTime, @EndTime) AS DECIMAL(18,2)) / 60) AS RoundedMinutes

Open in new window


Raj
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

752 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