I'm using one of Michael's versions and I'm getting NULL values when there is a date and the time is 0.
i.e.:
last_run_datelast_run_timeLastRunDateTime
20081118 0 NULL
this one:
CREATE FUNCTION [dbo].[IntsToDate]
(
@Date integer,
@Time integer
)
RETURNS TABLE WITH SCHEMABINDING
AS RETURN
SELECT FullDateTime =
-- convert date
dateadd(dd,((@Date)%100)-1,
dateadd(mm,((@Date)/100%100)-1,
dateadd(yy,(nullif(@Date,0)/10000)-1900,0)))+
-- convert time
dateadd(ss,@Time%100,
dateadd(mi,(@Time/100)%100,
dateadd(hh,nullif(@Time,0)/10000,0)))
;
(I'm reasonably good with T-SQL but when you start getting into this date/time and math stuff I tend to go a bit cross-eyed...)