user1076439
user1076439

Reputation: 111

Adding datediff results to a new column

I can easily use the datediff function to get the results between 2 date and time values as number of hours but how do I put this into a new column beside the second date/time column with a custom name along the lines of HoursTrained?

Thanks!

Upvotes: 0

Views: 6255

Answers (1)

Mahmoud Gamal
Mahmoud Gamal

Reputation: 79969

If I don't miss something, then I thik you are looking for something like:

Select DateFrom, DateTo, 
       DateDiff(day, DateFrom, DateTo) as 'Difference in Days',
       DateDiff(hour,DateFrom, DateTo) as 'Difference in Hours'
From TableName

Upvotes: 2

Related Questions