> I am using ColdFusion MX 7 and a MySQL database.  I have a database of surveys
> taken with each record having a date that the survey was taken.

MySQL and dates are a strange thing.  The biggest issue is that dates
are treated differently depending on the version of the MySQL server
you're working with.

If it were up to me I would be using the DateDiff function to get your
range, here are some MySQL specific examples:

If your starting and ending dates are 05/01/2005 and 05/31/2005

SELECT *
FROM Surveys
WHERE DateDiff(Surveys.ShopDate, '2005-05-01') >= 0 AND
DateDiff(Surveys.ShopDate, '2005-05-31') <= 0

Yes, for those that use MSSQL's DateDiff that's WAY different syntax.
According to the docs:
DATEDIFF() returns expr1 – expr2 expressed as a value in days from one
date to the other. expr1  and expr2 are date or date-and-time
expressions. Only the date parts of the values are used in the
calculation.

Now for the downside - DateDiff() and other date functions did not
enter the MySQL scene until version 4.1.1 which means you need to make
sure your version of MySQL supports the above mentioned code.

Hatton

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255904
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to