如何选择当前日期到以后的日期记录. [英] how to select current date to later date record.

查看:66
本文介绍了如何选择当前日期到以后的日期记录.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生
我想选择将当前日期记录到以后的事件中.



Dear sir
i want to select record current date to later events.



EventDate	EventDateTo	EventDetails
19 Jan 2012	21 Jan 2012	Test2
12 Jan 2012	14 Jan 2012	Test1
23 Feb 2012	24 Feb 2012	test2
23 Feb 2012	24 Feb 2012	test



在此先感谢



thanks in advance

推荐答案

如果要获取当前或将来日期的所有记录,则可以编写sql查询,如下所示:

if you want to get all records of current or future date, then you can write sql query as follows:

select eventDate, eventDetails from table_name where eventDate >= getDate()


您必须将数据转换为日期:

You''ll have to convert the data to a date:

select eventDate, eventDetails from table_name where convert(datetime, eventDate) >= getdate()



请不要在大表上查询会很慢.将日期存储为日期而不是varchar会更好.这样,您还可以确保只获得有效的日期值.



Please not that on a large table this query will be quite slow. It would be much better to store the date as a date, not as varchar. That way you could also be sure that you only get valid date values.


这篇关于如何选择当前日期到以后的日期记录.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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