SSIS如何将DMY格式格式化为YDM [英] SSIS how to format DMY format into YDM
本文介绍了SSIS如何将DMY格式格式化为YDM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如第三方数据源以03/05/14日期格式存储,
我需要将日期输入2014/05/03,我该怎么办这样做
SQL Server示例
源数据:'03 / 05/14'
转换方法:
Such as third-party data sources stored in the "03/05/14" date format,
I need to put the date into a "2014/05/03", how do I do it
SQL Server Example
Source data: '03/05/14'
Transformation methods:
select convert(datetime, '03/05/14', 3)
结果:2014-05-03 00:00:00.000
Result:2014-05-03 00:00:00.000
推荐答案
我不是确切地说把日期变成'2014/05/03'是什么意思......
SQL Server ,日期值以内部格式存储,不是类似DD / MM / YY,YYYY / MM / DD等。但是有规则了解不同的 datetime 格式被解释。如果您想了解更多信息,请阅读本文:
终极日期时间数据类型指南 [ ^ ]
以下是如何以YYYY / MM / DD格式获取日期:
1。 SQL Server :
Hi,
I am not sure what exactly you mean by saying "to put the date into a '2014/05/03'"...
In SQL Server, date values are stored in an internal format, not something like "DD/MM/YY", "YYYY/MM/DD", etc. But there are rules for how different datetime formats are interpreted. If you'd like to know more about it, then read this article:
The ultimate guide to the datetime datatypes[^]
Here's how to get the date in "YYYY/MM/DD" format:
1. SQL Server:
SELECT CONVERT(VARCHAR(10), GETDATE(), 111);
结果:
Result:
2014/05/03
2。 SSIS :
2. SSIS:
(DT_STR, 4, 1252) DATEPART("yy", GETDATE()) + "/" + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("mm", GETDATE()), 2) + "/" + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("dd", GETDATE()), 2)
结果:
Result:
2014/05/03
我用这个工具测试过它:
SSIS Expression Editor&测试人员 [ ^ ]
如果您需要别的东西,请告诉我。
这篇关于SSIS如何将DMY格式格式化为YDM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文