How do I strip the date off of a datetime string in SQL SSIS?

前端 未结 5 634
情话喂你
情话喂你 2020-12-20 23:49

I\'m working on a data warehouse project and would like to know how to (preferably in a Derived Column component in a Data flow) strip the date piece off of a SQL datetime r

5条回答
  •  醉梦人生
    2020-12-21 00:17

    I personally use a series of functions for this. E.g.:

    ALTER FUNCTION [dbo].[TIMEVALUE]
    (
     @Datetime datetime
    )
    RETURNS datetime
    AS
    BEGIN
        RETURN (@Datetime - CAST(ROUND(CAST(@Datetime AS float), 0, 1) AS datetime))
    END
    

    I'd love to claim all the credit but it should really go to this guy.

提交回复
热议问题