Solved

Datetime Start End - minutes

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
In this article I will describe the Backup & Restore 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.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

12 Experts available now in Live!

Get 1:1 Help Now