Надеюсь, что это поможет
SELECT DATENAME(year, Datetime_Colum)+''+
SUBSTRING( CAST(CONVERT(DATE,Datetime_Colum,101)AS VARCHAR(8)),6,2)+''+
DATENAME(DAY, Datetime_Colum)+''+
DATENAME(hour, Datetime_Colum)+''+
DATENAME(minute, Datetime_Colum)+''+
DATENAME(second, Datetime_Colum)
FROM [dbo].[Table]
- // ========================================================================
Функция:
CREATE FUNCTION udf_Convert_Datetime_To_INT
(
@DATETIME DATETIME
)
RETURNS BIGINT
AS
BEGIN
DECLARE @Result BIGINT
SELECT @Result = CAST(( DATENAME(YEAR,@DATETIME) +''+
SUBSTRING( CAST(CONVERT(DATE,GETDATE(),101)AS VARCHAR(8)),6,2)+''+
DATENAME(DAY,@DATETIME)+''+
DATENAME(hour, @DATETIME)+''+
DATENAME(minute, @DATETIME)+''+
DATENAME(second, @DATETIME)) AS BIGINT)
RETURN @Result
END
GO
PRINT DBO.udf_Convert_Datetime_To_INT (GETDATE())
Результат: 20110511152843