Solved

Datetime Start End - minutes

Posted on 2011-02-26
1
233 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

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

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

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

627 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