如何在SQL SSIS中从日期时间字符串中删除日期? [英] How do I strip the date off of a datetime string in SQL SSIS?
问题描述
我正在从事一个数据仓库项目,想知道如何(最好是在数据流中的派生列组件中)从SQL日期时间记录中删除日期。
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 record.
一旦将日期时间转换为时间,我将对时间进行查询以在时间维度表中找到相关的时间记录。
Once I have the datetime converted to just a time I am going to do a lookup on the time to find the related time record in a time dimension table.
有人可以给我一个简单的函数来在派生的列转换中完成此操作吗?
Can someone give me a simple function to accomplish this inside a derived column transform?
示例:转换日期时间,例如 12/02/2008 11:上午32:21更改为简单的上午11:32:21。
Example: Transform a datetime such as "12/02/2008 11:32:21 AM" into simply "11:32:21 AM".
推荐答案
我只需要强制转换为 DT_DBTIME
类型(使用派生列转换或转换类型转换)。 DT_DBTIME
仅包含日期/时间的(小时,分钟,秒)部分,因此您将摆脱日期部分。
I would just do a cast to DT_DBTIME
type (using Derived Column transform, or Convert type transform). DT_DBTIME
contains just (hours, minutes, seconds) part of the date/time, so you'll get rid of the date part.
这篇关于如何在SQL SSIS中从日期时间字符串中删除日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!