Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Datetime Start End - minutes

Posted on 2011-02-26
1
Medium Priority
?
234 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 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 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