Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted
Updated 6-Apr-13 23:40pm
v2
Comments
OriginalGriff 7-Apr-13 5:41am    
And?
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

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

Try to convert:
SQL
SELECT CONVERT(SMALLDATETIME, '12:00') AS MyDateTime

and see what happens.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900