Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to get Two varchar values between difference time

Example:

Sql server 2008 query

SQL
select cast(dateadd(minute, datediff(minute,ShiftStart , ShiftEnd), 0) as time(0) ) FROM Accounts_DailyAttendance where UserID=2060 AND datename(month,processdate) ='September' and datepart(yyyy,processdate)=2014.


But I want Sql server 2005,How to get Shiftstart((varchar(50)) and Shiftend((varchar(50)) time between time.

EXAMPLE:
Shiftstart Shiftend
09:00 18:00

I want Result is 09:00:00 Hours in sql server 2005.
Posted
Updated 29-Dec-14 23:23pm
v2

1 solution

you can use this in sql server 2005
here is an eg

SQL
create table timediff (time1 varchar(50),time2 varchar(50));

insert into timediff  values('2011-12-09 08:40:00.000','2011-12-09 09:00:00.000');

SELECT convert(varchar,CAST(time2 AS DATETIME)-CAST(time1 AS DATETIME), 8)TIME_DIFF from timediff;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900