Click here to Skip to main content
13,086,662 members (55,903 online)
Rate this:
Please Sign up or sign in to vote.

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-
April 2013
07 Apr 2013
07 Apr
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.

Posted 6-Apr-13 23:39pm
Updated 6-Apr-13 23:40pm
OriginalGriff 7-Apr-13 5:41am
What have you tried?
Where are you stuck?
Sonal Wagh 7-Apr-13 5:47am
I mean how do i write multiple cases to match the filter format user entered with format in database.
e.g. when input id Apr 2012, the output will contain all dates with month April, 2012
when input is 24, all dates with date 24 will be displayed, etc.
Sonal Wagh 7-Apr-13 5:49am
I can easily achieve this by writing multiple queries for each case, but i want to write those in single query.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Please, read about datetime and smalldatetime data types[^] for MS SQL Server.

Try to convert:

and see what happens.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 7 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100