如何在ssis中获取带时间戳的文件名 [英] How to get filename with timestamp in ssis

查看:46
本文介绍了如何在ssis中获取带时间戳的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个输入文件,必须每天加载到我的表中.我收到以下格式示例 sample_20120518_160754.CSV 的文件.时间戳可能会有所不同,它不是当前时间戳

I have an input file which has to loaded daily to my table. I receive files in the following format sample sample_20120518_160754.CSV. Time stamps may vary, it is not current time stamp

我使用表达式来获取文件名和日期,但是如何获取文件的时间戳.

I have used expression to get the filename along with date, but how can i get timestamp of the file.

这是我用来获取文件和日期的表达式.

This was the expression i have used to get the filealong with date.

"sample_" + RIGHT("0" + (DT_STR,4,1252)DATEPART("yyyy", (DT_DATE)@[User::p_varAsOfDate]), 4) + RIGHT("0" + (DT_STR, 2, 1252)DATEPART("dd", (DT_DATE)@[User::p_varAsOfDate]), 2) + (DT_STR, 2, 1252)DATEPART("mm", (DT_DATE)@[User::p_varAsOfDate]) +"_"  +".CSV"  

这个表达式产生结果

sample_2012145_.CSV 现在我也想要文件的时间戳.

sample_2012145_.CSV now i want time stamp of the file also.

推荐答案

这里的表达式可以同时为您提供日期部分 + 时间部分.您可以在它们之间放置额外的分隔符来完成您想要的格式.

Here's the expression that will give you the datepart + the time part as well. You can put additional delimiters in between to accomplish the format that you want.

(DT_STR, 4, 1252)DATEPART("yyyy", @[System::ContainerStartTime]) + 
RIGHT("0" + (DT_STR, 2, 1252)DATEPART("mm", @[System::ContainerStartTime]), 2) + 
RIGHT("0" + (DT_STR, 2, 1252)DATEPART("dd", @[System::ContainerStartTime]), 2) +
RIGHT("0" + (DT_STR, 2, 1252)DATEPART("hh", @[System::ContainerStartTime]), 2) +
RIGHT("0" + (DT_STR, 2, 1252)DATEPART("mi", @[System::ContainerStartTime]), 2) +
RIGHT("0" + (DT_STR, 2, 1252)DATEPART("ss", @[System::ContainerStartTime]), 2) + 

您可以编辑上述表达式并使用您选择的另一个变量.我选择 ContainerStartTime 是因为它很容易.

you can edit the above expression and use another variable of your choice. I chose the ContainerStartTime because of the ease.

这篇关于如何在ssis中获取带时间戳的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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