Sqlquery用于两个日期之间的反向数据 [英] Sqlquery for retrive data between two dates

查看:73
本文介绍了Sqlquery用于两个日期之间的反向数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select USERID,checktime from CHECKINOUT where((CHECKTIME between 2012/06/01 and 2012/0630))order by CHECKTIME asc



这行代码不会检索任何值。您可以向我发送任何在两个日期之间检索数据的查询。


This line of code doesn't retrieve any value. Can u send me any query that retrieve data between two dates.

推荐答案

您有2012/0630而不是2012/06/30。另外,我认为日期应该是引号。
You have 2012/0630 instead of 2012/06/30. Also, I believe dates should be in quotes.


你必须在日期值周围加上引号:

You have to put quotes around date values :
select USERID,checktime from CHECKINOUT where((CHECKTIME between '2012/06/01' and '2012/06/30'))order by CHECKTIME asc



为了更方便,使用' - '代替'/',因为有些数据库不喜欢'/':


To be more portable use '-' instead of '/' as some databases don't like '/' :

select USERID,checktime from CHECKINOUT where((CHECKTIME between '2012-06-01' and '2012-06-30'))order by CHECKTIME asc


Bigyan,



首先问题,日期范围之间是否有数据?



它看起来就像在你的日期有一个错字,你错过了一个/



此外,没有必要支撑。



Bigyan,

First question, are there data between the date range?

It looks like there's a typo in your till date, you're missing a /

Besides, there is no need for the braces.

SELECT USERID,checktime FROM CHECKINOUT WHERE CHECKTIME BETWEEN '2012/06/01' AND '2012/06/30' ORDER BY CHECKTIME ASC





试试这个并告诉我们!



Try this and let us know!


这篇关于Sqlquery用于两个日期之间的反向数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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