SQL Server 2008中的自定义日期时间过滤器 [英] Custom datetime filter in SQL server 2008
问题描述
你好,
我正在根据用户输入的过滤器做一个过滤记录的申请。
我有一个下拉列表过滤器类型和过滤器字符串的一个文本框。
下拉列表中的过滤条件是:
?*,*?*,=,!=,>, > =,<,< =等等
我认为最终用户会将以下有效值放在文本框中 -
2013/04/04
2013年4月
2013
2013年4月7日
07年4月
12:00
11:30 PM
我的数据库表有以下字段 -
< b> uploaded_on (smalldatetime)
我必须编写查询,以便用户输入的任何过滤器都应该根据该过滤进行过滤。 />
谢谢。
Hello,
I am doing one application for filtering records according to filter entered by user.
I have one drop down list for filter types and one text box for filter string.
Filter conditions in drop down lists are :
?*, *?*, =, !=, >, >=, <, <=, etc
And i think end user will put following valid values in text box-
2013/04/04
April 2013
2013
07 Apr 2013
07 Apr
12:00
11:30 PM
My database table have following field-
uploaded_on (smalldatetime)
I have to write query such that whatever filter entered by user is, records should be filtered according to that.
Thanks.
推荐答案
请阅读 datetime和smalldatetime数据类型 [ ^ ]用于MS SQL Server。
尝试转换:
Please, read about datetime and smalldatetime data types[^] for MS SQL Server.
Try to convert:
SELECT CONVERT(SMALLDATETIME, '12:00') AS MyDateTime
看看会发生什么。
and see what happens.
这篇关于SQL Server 2008中的自定义日期时间过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!