SQLTeam.com | Weblogs | Forums

SQL Server conversion for TO_DATE

sql2008r2

#1

How to convert this oracle syntax to SQL server 2008 R2

select (TO_DATE('1040' ,'HH24MI') - TO_DATE('1020','HH24MI')) from dual;

Oracle Output: 0.0138888888888888888888888888888888888889

Im doing Oracle to SQL server Migration. need to replicate the same result .


#2

SELECT DATEDIFF(minute, '19000101 10:20', '19000101 10:40')


#3

thanks for your reply.
But when i run this Oracle query it give different result in Oracle.

select (TO_DATE('1040' ,'HH24MI') - TO_DATE('1020','HH24MI')) from dual;
Result:0.0138888888888888888888888888888888888889

Im doing Oracle to SQL server Migration. need to replicate the same result .


#4

select datediff(minute, cast('10:20' as time), cast('10:40' as time)) / (60.0 * 24) /* 60 * 24=#ofmins_in_a_day */


#5

Thanks a lot Scott Pletcher