简体   繁体   English

SQL服务器中的日期时间转换问题

[英]Datetime conversion problem in SQL Server

I have a flat file with the following format as datetime我有一个格式如下的平面文件作为日期时间

5/3/22 2:09:02 PM (MM/DD/YY HH:MM:SS) but it gets read in SQL Server as 2022-03-05 14:09:02 . 5/3/22 2:09:02 PM (MM/DD/YY HH:MM:SS)但它在 SQL 服务器中被读取为2022-03-05 14:09:02 I have used SSIS ETL to load the flatfile to DB.我已经使用 SSIS ETL 将平面文件加载到数据库。

How to fix this error?如何修复此错误? I was supposed to get 2022-05-03 14:09:02 in SQL Server.我应该在 SQL 服务器中获得2022-05-03 14:09:02 Suggest me the datatype as well也建议我的数据类型

This is a locale problem.这是一个语言环境问题。 It looks like your flat file has its dates encoded according to the American method and your database default locale is set to some European method.看起来您的平面文件的日期是根据美国方法编码的,并且您的数据库默认语言环境设置为某种欧洲方法。

When you set up your SSIS job, pick an American locale (US English will work) in the flat file connector properties panel.当您设置 SSIS 作业时,请在平面文件连接器属性面板中选择美国语言环境(美国英语将起作用)。 Then SSIS will handle your input date/time values the way you want.然后 SSIS 将以您想要的方式处理您输入的日期/时间值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM