Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

dates within range not being detected

Guest
Jun 06, 2009 Jun 06, 2009

Iam not sure if this problem is with ColdFusion or if it is with SQL Server.

The following is my code:

<cfparam default="#DateAdd("d", -7, Now())#" name="attributes.StartDate">
<cfparam default="#DateAdd("d", 1, Now())#" name="attributes.EndDate">


<cfquery name="login_records" datasource="#application.datasource#" username="#application.username#" password="#application.password#">
  SELECT *
  FROM tblLoginRecords
  WHERE LoginDate
  BETWEEN <cfqueryparam cfsqltype="cf_sql_date" value="#attributes.StartDate#">
  AND <cfqueryparam cfsqltype="cf_sql_date" value="#attributes.EndDate#">
  ORDER BY UserName ASC, LoginDate DESC
</cfquery>

Basically it is not returning dates at the end of the range. At first I thought it was because the EndDate date creation assumes a start time of 12am but even when I used createDateTime and set it for 23,59,59 it still wouldn't return the dates at the end of the range. Any help would be greatly appreciated.

Cheers

458
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Jun 06, 2009 Jun 06, 2009

i think you might want CF_SQL_TIMESTAMP instead of cf_sql_date.

Translate
Enthusiast ,
Jun 06, 2009 Jun 06, 2009

i think you might want CF_SQL_TIMESTAMP instead of cf_sql_date.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 06, 2009 Jun 06, 2009
LATEST

Thanks heaps for that I was going mental trying to find a solution.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources