I just found the following code:
CREATE FUNCTION dbo.JoinDateAndTime
(
@d datetime,
@t datetime
)
RETURNS Datetime
as
BEGIN
declare @res datetime
set @res = convert (datetime, Convert(varchar(10), @d, 104) + ' ' + convert(varchar(8), @t, 108), 104)
return @res
END
go
After seeing the answers to How to the get current date without the time part I'm sure that involving conversions to varchar can't be the best solution.
BTW I searched SO for this question, but only found a solution for mySql.