I've got a form which submits 3 fields, year, month and day. In the db, I'm
storing a standard date/time field (yyyy-mm-dd hh:mm:ss). The time portion
of this is irrelevant for this form.

What I'd like to accomplish is allowing the user to submit values for one or
more of these fields and search the date column based on the values. So:

year=2006 (return all records with a year of 2006)
year=2005, month=12 (return all records from dec 2005)
month=9, day=21 (return all records on sept 21 of any year.)
day=21 (return all records on the 21st of any month/year)

Admittedly this last example isn't all that useful, but it's possible. So
right now this is what my query looks like:
[php]
<cfif FORM.year IS NOT "">
        AND n.due_datetime LIKE '#FORM.year#-%'
</cfif>
<cfif FORM.month IS NOT "">
        AND n.due_datetime LIKE '%-#FORM.month#-%'
</cfif>
<cfif FORM.day IS NOT "">
        AND n.due_datetime LIKE '%-#FORM.year# %'
</cfif>
[/php]

The problem is that this only allows the user to search against one of the
fields; I need to do any/all. Does anyone have any ideas how I might
accomplish this?

<!----------------//------
andy matthews
web developer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--------------//--------->


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:227004
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to