Solved

Datetime Start End - minutes

Posted on 2011-02-26
1
228 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
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 to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

11 Experts available now in Live!

Get 1:1 Help Now