date formatting and SQL
I've been having a few issues with dates and SQL recently so I thought I would quickly post my solution. When searching in SQL with dates this is what I tend to use:
<cfset createODBCDate(form.dateFrom)>
<cfset createODBCDate(form.dateTo)>
<cfquery name="qGetComments"datasource="#application.defaultProperties.datasourceName#">
SELECT comments.comment, comments.commentDate, tbluser.firstName, tbluser.lastName
FROM comments INNER JOIN
tbluser ON comments.staffID = tbluser.userID
WHERE (comments.studyID = #qStudyInfoList.studyId#) AND
comments.commentDate BETWEEN #LSParseDateTime(form.dateFrom)# AND #LSParseDateTime(form.dateTo)#
order by commentDate
</cfquery>
This helps when people are using differnt date formats as well.




