Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Timediff/datediff in MS SQL server 2000

Posted on 2003-03-27
Medium Priority
Last Modified: 2007-12-19
How can I calculate the time (hours and minutes) between startdate and enddate when datatype are datetime.

Ex hours and minutes spent on a project with startdate '2003-03-27 08:00:00' and enddate '2003-03-27 16:00:00'. Expected result is 8.

Question by:brekmar
  • 3
LVL 43

Expert Comment

by:Eugene Z
ID: 8217603
select DATEDIFF ( dd ,'2003-03-27 08:00:00'  , '2003-03-27 16:00:00' )
LVL 43

Accepted Solution

Eugene Z earned 120 total points
ID: 8217609
previous was for days;
this one for hours
select DATEDIFF ( hh,'2003-03-27 08:00:00'  , '2003-03-27 16:00:00' )
LVL 43

Expert Comment

by:Eugene Z
ID: 8217618

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

581 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