Reputation: 1
I have one table in that they are four columns like
startdate varchar(15),
enddate varchar(15),
starttime varchar(15),
endtime varchar(15)
Here I need to get the time in hours between these two dates (ex: 6/7/2010,6/12/2010) if I pass these days as inputs.
Upvotes: 0
Views: 710
Reputation: 37537
You're looking for the DATEDIFF function:
SELECT DATEDIFF(hh, startdate, enddate)
Upvotes: 0
Reputation: 238068
It's usually as simple as:
select datediff(hour, starttime, endtime)
For example:
select datediff(hour, '2010-01-01 12:00', '2010-01-02 13:45')
Prints:
25
Upvotes: 2