Hi Guys,
I have created a function which will take two parameters as startdate, enddate and returns hours from that. here i am getting both the total hours but i need to get individual month hours from that.
Regards, kumar
Hi Guys,
I have created a function which will take two parameters as startdate, enddate and returns hours from that. here i am getting both the total hours but i need to get individual month hours from that.
Regards, kumar
Use datediff
CREATE TABLE dbo.Duration
(
startDate datetime2
,endDate datetime2
)
INSERT INTO dbo.Duration(startDate,endDate)
VALUES('2007-05-06 12:10:09','2007-05-07 12:10:09')
SELECT DATEDIFF(HOUR,startDate,endDate) AS 'Duration'
FROM dbo.Duration;
-- Returns: 24