Well, I figured out on my own. There is no need of STR_TO_DATE
function in SQL Query here.I just used DATE()
function to retrieve the date part. Also, I noticed that specifying the mask while using DateFormat
function as yyyy-mm-dd
was helpful for coldfusion rather than specifying any other format.
Thanks to all for your help. Appreciated.
Working Code:
<cfparam name="form.startdate" default="#DateFormat(dateAdd('d',-40,now()), 'yyyy-mm-dd')#">
<cfparam name="form.enddate" default="#DateFormat(dateAdd('d',-1,now()), 'yyyy-mm-dd')#">
<cfquery datasource = "XX.XX.X.XX" name="master">
SELECT DATE(Timedetail) as THIRDCONN,count(Timedetail) as THIRDOCCURANCES ,EVENTS
FROM MyDatabase
WHERE EVENTS = "THIRD"
GROUP BY THIRDCONN;
</cfquery>
<cfquery dbtype="query" name="detail">
SELECT *
FROM master
WHERE THIRDCONN >= <cfqueryparam value="#form.startdate#" cfsqltype="cf_sql_date">
AND THIRDCONN < <cfqueryparam value="#form.enddate#" cfsqltype="cf_sql_date">;
</cfquery>