Select * from myDATA
where MONTH(#form.dateFIELD#) = #DatePart("m",form.monthSEL)#
_____
From: Les Mizzell [mailto:[EMAIL PROTECTED]
Sent: Friday, September 10, 2004 4:46 PM
To: CF-Talk
Subject: Dates in Queries give me fits! Advice please?
I need to select all records (SQL Server) where are particular date
field matches the MONTH selected. My problem comes in where the field
itself is a variable coming from a form.
On the form, there's a dropdown that shows the last 24 months like
(example displays 2 months ago):
<option value="#DateAdd("m",-2,Now())#">
#DateFormat(DateAdd("m",-2,Now()), "mmmm, yyyy")#
</option>
Here's the current SQL (simplified) that ain't working correctly:
Select * from myDATA
where #form.dateFIELD# = #DatePart("m",form.monthSEL)#
#form.dateFIELD# is a dynamic value where you can pick which column to
search. Could be "start_date", "assigned_date", "complete_date"....
So, I need to extract the month value from the dynamic field and compare
it to the value passed from the form.
1. Am I passing the correct value from the form to start with?
2. Using #DatePart("m",form.dateFIELD)# doesn't work correctly - so this
is my main problem. Syntax is throwing me off...
2. How does it know the difference between June 2004 and June 2003?
Pointers?
--
Les Mizzell
_____
[HYPERLINK "http://www.houseoffusion.com/lists.cfm/link=t:4"Todays Threads]
[HYPERLINK "http://www.houseoffusion.com/lists.cfm/link=i:4:177978"This
Message] [HYPERLINK
"http://www.houseoffusion.com/lists.cfm/link=s:4"Subscription] [HYPERLINK
"http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=678.598.4"Fast
Unsubscribe] [HYPERLINK "http://www.houseoffusion.com/signin/"User Settings]
[HYPERLINK
"https://www.paypal.com/cgi-bin/webscr?amount=&item_name=House+of+Fusion&bus
iness=donations%40houseoffusion.com&undefined_quantity=&cmd=_xclick"Donation
s and Support]
_____
HYPERLINK "http://www.houseoffusion.com/banners/view.cfm?bannerid=39" \n
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.759 / Virus Database: 508 - Release Date: 9/9/2004
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.759 / Virus Database: 508 - Release Date: 9/9/2004
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

