This Scalar-valued function return a real datetime from a Midas datetime. In midas, the date is the number of day since 1971-12-31.
ALTER FUNCTION [dbo].[udf_DateMidasToSql] ( @Days int ) RETURNS datetime AS BEGIN RETURN dateadd(day, @Days, '1971-12-31') END