SQL日期转换 [英] SQL Date conversion

查看:57
本文介绍了SQL日期转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我从XML文件中获取一串日期,如下所示

'2015-02-16T16 :54:00.000 + 00:00'。

我需要将此转换为日期时间才能获得日期转换错误。



请帮帮我解决问题。





谢谢...

Hi Friends,

I'm getting a string of date from XML file as shown below
'2015-02-16T16:54:00.000+00:00'.
I need to convert from this to datetime getting date conversion error.

Please help me to fix the issue.


Thanks...

推荐答案





这是一个你可以尝试的解决方案。



Hi,

Here is a solution you can try.

select CONVERT(DATETIME,CONVERT(VARCHAR(22),'2015-02-16T16:54:00.000+00:00'),126)





以下是XML格式的一些特殊字符,无法转换为日期时间格式。所以你需要根据你的要求进行格式化。



谢谢

Sisir Patro



Here are some special characters are there in the XML format which can not be converted into datetime format. So you need to format it based on your requirement.

Thanks
Sisir Patro


试试使用InvariantCulture设置进行转换。请参见此处 [ ^ ]示例。
Try converting with the InvariantCulture settings. See here[^] for an example.


这篇关于SQL日期转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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