[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Get time in hours from start time and end time MSSQL

Posted on 2016-07-27
7
Medium Priority
?
39 Views
Last Modified: 2016-08-22
I have a table with two time columns and I need to get the number of hours from the start time and end time.  I'm absolutely blank.  Any help would be appreciated.  many thanks in advance.  It is a simple table, example below.

Select pdsStartTime, pdsEndTime from programDaySchedule

Open in new window

0
Comment
Question by:meldraper
[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
  • 3
  • 2
7 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 41731722
SELECT DATEDIFF(hour, pdsStartTime, pdsEndTime) as hours_diff
FROM programDaySchedule

Open in new window

1
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points (awarded by participants)
ID: 41731726
The above just takes the hours.  A more precise answer would be to get the difference in minutes and divide by 60.

SELECT DATEDIFF(minute, pdsStartTime, pdsEndTime) / 60.0
FROM programDaySchedule

Open in new window

1
 
LVL 13

Expert Comment

by:Dustin Saunders
ID: 41731727
Select the dateDiff in hours:

select DATEDIFF(HOUR,pdsStartTime,pdsEndTime) from programDaySchedule

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 13

Expert Comment

by:Dustin Saunders
ID: 41731729
Oops, stepped on your toes Jimbo!
0
 

Author Comment

by:meldraper
ID: 41731738
Thank you Jimbo.  That's exactly what I needed.  It works great.
0
 
LVL 13

Expert Comment

by:Dustin Saunders
ID: 41756104
First working answer.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

649 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