This code converts a SQL Server datetime value to a time only datetime value with the time as an offset from 1900-01-01 00:00:00.000. The function on the link below has this code as a user defined function.By convention, time only is usually stored this way in SQL Server. The reason is that the time can be added to a datetime value containing the date only, and produce the original date and time.Time Only Function: F_TIME_FROM_DATETIMEhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=65358select a.DT, Time_Only = a.DT-dateadd(dd,datediff(dd,0,a.DT),0)from ( -- Test Dates select DT = convert(datetime,'2006-04-27 07:23:11.247') union all select DT = convert(datetime,'2006-04-27 07:21:09.333') union all select DT = convert(datetime,'1753-01-01 00:00:00.003') union all select DT = convert(datetime,'1753-01-01 07:21:09.997') union all select DT = convert(datetime,'1753-01-01 23:59:59.997') union all select DT = convert(datetime,'9999-12-31 00:00:00.003') union all select DT = convert(datetime,'9999-12-31 07:21:09.997') union all select DT = convert(datetime,'9999-12-31 23:59:59.997') ) aResults:DT Time_Only----------------------- -----------------------2006-04-27 07:23:11.247 1900-01-01 07:23:11.2472006-04-27 07:21:09.333 1900-01-01 07:21:09.3331753-01-01 00:00:00.003 1900-01-01 00:00:00.0031753-01-01 07:21:09.997 1900-01-01 07:21:09.9971753-01-01 23:59:59.997 1900-01-01 23:59:59.9979999-12-31 00:00:00.003 1900-01-01 00:00:00.0039999-12-31 07:21:09.997 1900-01-01 07:21:09.9979999-12-31 23:59:59.997 1900-01-01 23:59:59.997(8 row(s) affected)
CODO ERGO SUM