SSIS 字符串转时间格式注意事项
2014-04-10 10:08
609 查看
花了两天时间,终于把字符串 转成Integration Services 数据类型的时间格式。
微软官方说明中,当数据进入包中的数据流时,提取这些数据的源会将数据转换为 Integration Services 数据类型。为数值数据分配数值数据类型,为字符串数据分配字符数据类型,为日期分配日期数据类型。 其他数据,如 GUID 和二进制大型对象块 (BLOB),也要分配相应的 Integration Services 数据类型。 如果数据的数据类型无法转换为 Integration Services 数据类型,则会发生错误。
对于时间格式的转换,需要特别注意,需要转换的字符串格式。 在微软官网说明中有一篇文章,对这一转换了做了详细的说明。
http://technet.microsoft.com/zh-cn/library/ms345165%28v=sql.90%29.aspx http://technet.microsoft.com/zh-cn/library/ms141036%28v=SQL.90%29.aspx
字符串转 时间类型,字符串需要对应的格式。 如 yyyy.mm.dd hh:mm:ss 是无法转换为时间格式的,需要对字符串做预处理。
Converting Between Strings and Date/Time Data Types
The following table lists the results of casting or converting between date/time data types and strings:
When you use the cast operator or the Data Conversion transformation, the date or time type data type will be converted to the corresponding string format. For example, the DT_DBTIME data type will be converted to a string that has the format, "hh:mm:ss".
When you want to convert from a string to a date or time data type, the string must use the string format that corresponds to the appropriate date or time data type. For example, to successfully convert some date strings to the DT_DBDATE data type, these
date strings must be in the format, "yyyy-mm-dd".
In the format for DT_FILETIME and DT_DBTIMESTAMP fff is a value between 0 and 999 that represents fractional seconds.
In the date format for DT_DBTIMESTAMP2, DT_DBTIME2, and DT_DBTIMESTAMPOFFSET, fffffff is a value between 0 and 9999999 that represents fractional seconds.
The date format for DT_DBTIMESTAMPOFFSET also includes a time zone element. There is a space between the time element and the time zone element.
微软官方说明中,当数据进入包中的数据流时,提取这些数据的源会将数据转换为 Integration Services 数据类型。为数值数据分配数值数据类型,为字符串数据分配字符数据类型,为日期分配日期数据类型。 其他数据,如 GUID 和二进制大型对象块 (BLOB),也要分配相应的 Integration Services 数据类型。 如果数据的数据类型无法转换为 Integration Services 数据类型,则会发生错误。
对于时间格式的转换,需要特别注意,需要转换的字符串格式。 在微软官网说明中有一篇文章,对这一转换了做了详细的说明。
http://technet.microsoft.com/zh-cn/library/ms345165%28v=sql.90%29.aspx http://technet.microsoft.com/zh-cn/library/ms141036%28v=SQL.90%29.aspx
字符串转 时间类型,字符串需要对应的格式。 如 yyyy.mm.dd hh:mm:ss 是无法转换为时间格式的,需要对字符串做预处理。
Converting Between Strings and Date/Time Data Types
The following table lists the results of casting or converting between date/time data types and strings:
When you use the cast operator or the Data Conversion transformation, the date or time type data type will be converted to the corresponding string format. For example, the DT_DBTIME data type will be converted to a string that has the format, "hh:mm:ss".
When you want to convert from a string to a date or time data type, the string must use the string format that corresponds to the appropriate date or time data type. For example, to successfully convert some date strings to the DT_DBDATE data type, these
date strings must be in the format, "yyyy-mm-dd".
Data type | String format |
---|---|
DT_DBDATE | yyyy-mm-dd |
DT_FILETIME | yyyy-mm-dd hh:mm:ss:fff |
DT_DBTIME | hh:mm:ss |
DT_DBTIME2 | hh:mm:ss[.fffffff] |
DT_DBTIMESTAMP | yyyy-mm-dd hh:mm:ss[.fff] |
DT_DBTIMESTAMP2 | yyyy-mm-dd hh:mm:ss[.fffffff] |
DT_DBTIMESTAMPOFFSET | yyyy-mm-dd hh:mm:ss[.fffffff] [{+|-} hh:mm] |
In the date format for DT_DBTIMESTAMP2, DT_DBTIME2, and DT_DBTIMESTAMPOFFSET, fffffff is a value between 0 and 9999999 that represents fractional seconds.
The date format for DT_DBTIMESTAMPOFFSET also includes a time zone element. There is a space between the time element and the time zone element.
相关文章推荐
- sqlserver中时间格式的字符串传递时的注意事项
- oracle时间分钟格式注意事项
- scanf函数中的格式字符串及注意事项
- 将JSON格式字符串转成对象、数组、取值等(注意事项)
- 日期转换需要注意的事项,解析日期格式的字符串
- 时间格式注意事项
- c风格字符串注意事项
- C#语言之“string格式的日期时间字符串转为DateTime类型”的方法
- SSIS ->> 生成时间格式
- s:if标签字符串比较注意事项
- 时间DateTime类型转换为字符串String格式方法汇总 获得最后一次编译时间
- 字符串转换为日期时间格式及其错误处理(转)
- 20-获得系统当前时间的字符串格式(字符串处理)
- 关于Java字符串数组的额外注意事项
- Ajax--json(Ajax调用返回json封装代码、格式及注意事项)
- mybatis在映射文件里面判断字符串注意事项
- C#语言之“string格式的日期时间字符串转为DateTime类型”的方法
- 1. 当前时间转换为字符串格式2.jdbc.properties常用配置
- sqlserver 不规则字符串转换为时间格式需要的格式
- Java 取得 30 分钟前的时间 字符串格式