如何从 SQL SSIS 中的日期时间字符串中去除日期? [英] How do I strip the date off of a datetime string in SQL SSIS?

查看:22
本文介绍了如何从 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 AM")转换为简单的11:32:21 AM".

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆