CREATE FUNCTION [dbo].[GetPicassoDateTimeAsRealDateTime] (@ADateTime VARCHAR(8), @ATime VARCHAR(5) )  
RETURNS DATETIME AS    
BEGIN 
--Created AV 2008 0724

  DECLARE @DayStarts VARCHAR(5)

  DECLARE @Result DATETIME

  SELECT @DayStarts = ISNULL(KeyValue, '07:00') FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'Arr24Hoursstarts'

  SET @Result = CONVERT(DATETIME, @ADateTime,112) + CONVERT(DATETIME, @ATime, 108)

  IF @ATime < @DayStarts   
    SET @Result = @Result + 1
  

  RETURN (@Result)

END
