Last active
March 10, 2019 12:19
-
-
Save ezhov-da/39a98bf53d6803c2b62eb7d8b448e887 to your computer and use it in GitHub Desktop.
sql mssql склеивание даты и времени из разных дат
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[code:]sql[:code]use OTZ | |
go | |
--select OTZ.dbo.fnc_E_concatDate(getdate() + 1, getdate()) | |
----------------------------------------------------------------------- | |
--> автор : Ежов Д.А. | |
--> дата создания : 2016-11-29 14:09 | |
--> описание : функция склеивает две даты и берет дату из первой, время из второй | |
------------------------------------------------------------------------ | |
CREATE FUNCTION [dbo].fnc_E_concatDate | |
( | |
@param1 datetime, | |
@param2 datetime | |
) | |
RETURNS datetime | |
AS | |
BEGIN | |
return convert | |
( | |
datetime, | |
left (convert(varchar, @param1, 120), 10) | |
+ ' ' + | |
right (convert(varchar, @param2, 120), 8), | |
120 | |
) | |
END | |
[/code] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment