如何将包内的字符串格式的时间戳转换为日期时间数据类型?
有人可以指导我如何使用派生列将来自平面文件源的 MM/DD/YYYY HH:MM
转换为日期时间到 ole db 目标。
这就是我的流程。
Flatfile -> Data Coversion -> Derived Column
Could someone guide me on how to convert MM/DD/YYYY HH:MM
that comes from a flat file source as a string to a datetime to a ole db destination using the derived column.
This is my flow.
Flatfile -> Data Coversion -> Derived Column
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几种方法可以实现这一目标。您可以使用
派生列转换
来转换值或者您可以将平面文件连接上的平面文件列声明为数据类型数据库的列时间戳 [DT_DBTIMESTAMP]
。步骤1 - 8 描述第一个选项,步骤9 描述第二个选项。分步过程:
此示例使用屏幕截图 #1 中所示的名为
Source.txt
的平面文件。平面文件连接
的配置如屏幕截图#2和#3所示。数据流任务
的配置如屏幕截图#4所示。平面文件源的配置如屏幕截图 #5 所示。
派生转换
任务的配置如屏幕截图#6 所示,使用类型转换DT_DBTIMESTAMP 将字符串值转换为日期时间值。OLE DB 目标
的配置如屏幕截图 #7 所示。屏幕截图 #8 显示示例包执行。
Screenshot #9 显示包执行后 SQL 表中的数据。
另一种更简单的方法是将包含日期时间值的列声明为数据类型
数据库时间戳 [DT_DBTIMESTAMP]
,如屏幕截图 #10 所示。这样,您就不需要派生列转换
,并且数据流任务
将如屏幕截图#11所示。您可以直接将平面文件
列映射到OLE DB目标
列。希望有帮助。
屏幕截图 #1:
屏幕截图 #2:
屏幕截图 #3:
屏幕截图 #4:
屏幕截图 #5:< /strong>
屏幕截图#6:
屏幕截图 #7:
屏幕截图 #8:< /strong>
屏幕截图#9:
屏幕截图 #10:
屏幕截图 #11:< /strong>
There are couple of ways to achieve this. You can use the
Derived Column transformation
to convert the value or you can declare the flat file column on the Flat File Connection as column of data typedatabase timestamp [DT_DBTIMESTAMP]
. Steps 1 - 8 describes the first option and step 9 describes the second option.Step-by-step process:
This example uses the flat file named
Source.txt
shown in screenshot #1.Flat File Connection
is configured as shown in screenshots #2 and #3.Data Flow Task
is configured as shown in Screenshot #4.Flat File Source is configured as shown in Screenshot #5.
Derived Transformation
task is configured as shown in screenshot #6 using the type cast DT_DBTIMESTAMP to convert the string value to date time value.OLE DB Destination
is configured as shown in screenshot #7.Screenshot #8 displays the sample package execution.
Screenshot #9 displays the data in the SQL table after the package execution.
another easier way to do this to declare the column that contains the date time value as data type
database timestamp [DT_DBTIMESTAMP]
as shown in screenshot #10. This way you don't need aDerived Column Transformation
and theData Flow Task
will be as shown in screenshot #11. You can directly map theFlat File
columns to theOLE DB destination
columns.Hope that helps.
Screenshot #1:
Screenshot #2:
Screenshot #3:
Screenshot #4:
Screenshot #5:
Screenshot #6:
Screenshot #7:
Screenshot #8:
Screenshot #9:
Screenshot #10:
Screenshot #11: