Category Archives: Code

Create dropdown selection for last 12 months.

Simple Coldfusion method for creating a select dropdown form element of the last 12 months sorted descending. The report-date is formatted for oracle queries. Change the dateFormat mask to fit your needs. <cfselect name=”report_date”> <cfloop from=”1″ to=”12″ index=”x” step=”1″> <cfset … Continue reading

Posted in Code | Comments Off on Create dropdown selection for last 12 months.

Temp tables and bad habits

We often have need to hold the results of a query in a temporary table so we can join or perform other tasks in later queries. <cfquery name=”Q1″ datasource=”myDsn”> select * into ##temp1 from mytable </cfquery> It is nice that … Continue reading

Posted in Code, Coldfusion, SQL | Comments Off on Temp tables and bad habits

isNull

Occasionally a field is blank but we have to sometimes have to show a default value or a value from another field. SQL gives us a nice tag to use: isnull(field1, field2) as name or isnull(field1, ‘n/a’) as name or … Continue reading

Posted in Code, Coldfusion, Snippets, SQL | Comments Off on isNull

Coldfusion output value formats

a library of things I use regularly but can never find when I need them. I will add to it over time. #datetime(fieldname, “mm/dd/yyyy”)# #DOLLARFORMAT(fieldname)# Excel formatting: color alternating rows <tr bgcolor=”###iif(currentrow MOD 2,DE(‘ffffff’),DE(‘ffff99’))#”> number as text in excel <td … Continue reading

Posted in Code, Coldfusion, Snippets | Comments Off on Coldfusion output value formats

Select TOP n vs Set Rowcount n

We had an issue this week while migrating our databases from Sybase to SQL SERVER. In sybase we would use SET ROWCOUNT 1 if we wanted to return only 1 record within a cfquery. Works just fine and it is … Continue reading

Posted in Code, Problems & Fixes | Comments Off on Select TOP n vs Set Rowcount n