TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Basit Khan
NA
336
120.9k
Get Hour & Time in SQL
Nov 19 2015 1:22 AM
Dear
In my table I have two Column Start & End both Data Type is datetime.
I want to get the hour and time.
I used this one for hour
DATEDIFF(hour,Dr_TimeStart,Dr_TimeEnd)
I got the hour. But when the Start and End column data are less then hour means time, Start is 0:00 and End 0:15 then return hour is 0
that's why i used min
DATEDIFF(mi,Dr_TimeStart,Dr_TimeEnd)
then i used the case
case when DATEDIFF(hh, dbo.Trn_Daily3.Dr_TimeStart, dbo.Trn_Daily3.Dr_TimeEnd) > 0 then DATEDIFF(hh, dbo.Trn_Daily3.Dr_TimeStart, dbo.Trn_Daily3.Dr_TimeEnd) else DATEDIFF(mi, dbo.Trn_Daily3.Dr_TimeStart, dbo.Trn_Daily3.Dr_TimeEnd) / 60 end
What i want is
I want to show the hour and time
Please help on this
Thanks
Basit.
Reply
Answers (
1
)
plz answer to this query
SQL - Create view using sql command “UNION” from multiple ta