sql server数据时间转换错误 [英] sql server data time convertion error

查看:93
本文介绍了sql server数据时间转换错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨每一个







i有查询类似



 选择 * 来自 GpsData 其中 DATE>转换( date '  23/02/2013' UNITID = '  amc007' 





它运行正常



但是



i希望得到我写的所有细节





 选择 * 来自 GpsData 其中 DATE> convert( date '  23/02/2013'





但是它显示错误



从字符串转换日期和/或时间时转换失败。







非常感谢您的帮助!!

解决方案

在第一个查询中除了UNITID =''amc007''

之外,两个查询之间有什么区别?如果您没有更改目标表中的结构,我不明白为什么您应该有错误。


转换日期格式时必须是

< b> YYYY-MM-dd

 选择 * 来自 GpsData 其中​​ DATE>转换( date '   2013/02/23 '



Happy Coding!

:)


如果您确实使用的是常量文字日期而不是变量日期,请使用以下语法。使用这种语法(yyyy-mm-dd),你不必转换日期格式。



从GpsData中选择* DATE> '' 2013年2月23日 ''


hi every one



i have query like

select * from GpsData where DATE>convert(date,'23/02/2013') and UNITID='amc007'



it running fine

but

i want to get all details i wrote like this


select * from GpsData where DATE>convert(date,'23/02/2013')



but it showing error like

Conversion failed when converting date and/or time from character string.



Much appreciated your help!!

解决方案

What is the difference between the two queries apart from UNITID=''amc007''
in the first query? If you have not changed the structure in the target table I don''t understand why you should have an error.


when converting date format must be
YYYY-MM-dd

select * from GpsData where DATE>convert(date,'2013/02/23')


Happy Coding!
:)


If you really are using a constant literal date rather than a variable date, use the following syntax. With this syntax (yyyy-mm-dd), you don''t have to convert the date format.

Select * from GpsData Where DATE>''2013-02-23''


这篇关于sql server数据时间转换错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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