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

前端 未结 5 636
情话喂你
情话喂你 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:16

    If you need to do this in a variable expression Michael's solution won't work, but you can use the following expression:

    (DT_DATE)(DT_DBDATE)GETDATE()
    

    (DT_DBDATE) converts the current date and time to a date only. But the new datatype is not compatiple with SSIS's datetime. Therefore you'll have to use (DT_DATE) for converting to a compatible type.

    Courtesy of this solution belongs to Russel Loski who has posted it in his blog: http://www.bidn.com/blogs/RussLoski/ssas/1458/converting-datetime-to-date-in-ssis

提交回复
热议问题