> I have a template that creates a query to get information for the month
> selected.  I am doing this by constructing a query like this :
>
> <CFSET Today = #CreateODBCDate(CreateDate(#ByYear#, #ByMonth#, 1))#>
> <CFSET EndDay = #CreateODBCDate(CreateDate(#ByYear#, #ByMonth#,
> DaysInMonth(#ByMonth#)))#>
>
> <CFQUERY name="Events" datasource="XXX">
> SELECT Location, Name, Time, Event_Date, Event_Number, Location
> FROM Tbl_Events
> WHERE Event_Date >= #Today#
> AND Event_Date <= #EndDay#
> </cfquery>
>
> ByYear is passed as the year selected from a form.
> ByMonth is the numerical month passed from a form.
>
> Now the issue is that when I pass September as "9" then the above
> cfset for
> EndDay returns 2000- 9-31 (obviously wrong) and November as "11" returns
> 2000-11-31 (also wrong).

On top of the DaysInMonth error - your SQL won't work properly, unless you
can guarantee that Event_Date is a date only, and doesn't include time

The way I'd do it is to use make EndDay as the first of the month higher,
and use "<"
Or you could use BETWEEN, as this handles what you're doing faster in SQL
than using >= and <=

Philip Arnold
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************


------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to