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

cfoutput query within HTML Select

Contributor ,
Aug 14, 2008 Aug 14, 2008
I have am update screen that allows the users to update the 'payment date' on a record. A simple query should load the available dates to be used to update this value.

The value that appears on the screen is the current value of get_record.payment_date, but when you click on the drop-down arrow, you get all the values in the calendar table, not just the answerset from the query. Any ideas why?



749
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

Contributor , Aug 15, 2008 Aug 15, 2008
Thanks cf_output and Dan -
I've changed my query to the following, and it works (I took Dan's suggestion and used the db representation of the current date/time, in SQL Server it is GetDate(); I've added the mask to get just the MM/DD/YYYY format):

<cfquery name="calendar" datasource="#attributes.datasource1#">
SELECT date FROM calendar
WHERE calendar.date >= (Convert(varchar(10), GetDate(),101))
AND calendar.type = 'B'
order by date
</cfquery>
Translate
Explorer ,
Aug 14, 2008 Aug 14, 2008
Your stating that query Calendar is returning results that are less than today's date, and is not type "B" ?
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
LEGEND ,
Aug 14, 2008 Aug 14, 2008
What might be causing the problem is that you are using an ambiguous string in your query instead of a date object.

If your db has a function that returns the current date, use it. Otherwise, use createdate to create your variable instead of dateformat.
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
Contributor ,
Aug 14, 2008 Aug 14, 2008
CF_ouput, yes the query results have only records that are of 'type B'. if the payment_date is 08/10/2008, then the dropdown list looks like:

08/10/2008
01/01/2006
01/02/2006

Where 01/01/2006 happens to be the first entry in the table.
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
Explorer ,
Aug 14, 2008 Aug 14, 2008
What happens when you run that query within sql (replacing the variables with values).

It looks like the dates are being compared with strings which is probably the problem, as Dan mentioned.
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
Contributor ,
Aug 14, 2008 Aug 14, 2008
I run a similar query on an input screen, and it works correctly. The only difference in this query, is that I am looking for then next day to be 'todays_date'. This query extracts the correct records.

<cfset date_today=#Now()#>
<cfset todays_date=#dateformat(dateadd('d',1,date_today), "MM/DD/YY")#>

<cfquery name="calendar" datasource="#attributes.datasource1#" >
SELECT date FROM calendar
WHERE (date >= '#todays_date#')
AND type = 'B'
order by date
</cfquery>
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
Contributor ,
Aug 15, 2008 Aug 15, 2008
LATEST
Thanks cf_output and Dan -
I've changed my query to the following, and it works (I took Dan's suggestion and used the db representation of the current date/time, in SQL Server it is GetDate(); I've added the mask to get just the MM/DD/YYYY format):

<cfquery name="calendar" datasource="#attributes.datasource1#">
SELECT date FROM calendar
WHERE calendar.date >= (Convert(varchar(10), GetDate(),101))
AND calendar.type = 'B'
order by date
</cfquery>
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