Creates a datetime2(7)
value with the date part from the first parameter and the time part from the second parameter.
DECLARE
@Date date = '2020-03-19',
@Time time = '11:45',
@NewDateTime datetime2(7);
SELECT @NewDateTime = SoftadminUtil.DateTime_FromDateAndTime(@Date, @Time); -- 2020-03-19 11:45
This can be useful when moving a calendar item to a new date without changing the time.
DECLARE
@DateTime datetime2(7) = '2020-03-19 11:45',
@Date date = '2019-12-31',
@NewDateTime datetime2(7);
SELECT @NewDateTime = SoftadminUtil.DateTime_FromDateAndTime(@Date, @DateTime); -- 2019-12-31 11:45
DECLARE
@DateTime datetime2(7) = '2020-03-19 11:45',
@Time time = '09:17',
@NewDateTime datetime2(7);
SELECT @NewDateTime = SoftadminUtil.DateTime_FromDateAndTime(@DateTime, @Time); -- 2020-03-19 09:17