Skip to main content
Inspiring
Nov 9, 2011 12:41 PM UTC
Question

What is the best way to check date range?

I have a table with some important dates in it. Say 11/9/2011, 11/10/2011 and 11/12/2011.

I have a form where users can select a start date for an event and an end date.

I will be displaying the results of the form in a table and I wanted to color code the row a different color if the a date within the date range between the start date and end date is one of the dates in the table.

I'm all set with coloring the row but I'm having trouble doing the date checks on the fly. Any ideas how I can do this?

So for instance Start date = 11/5/2011, end date = 12/01/2011. I need to first get the range of dates and second check each day to see if it is 11/9/2011, 11/10/2011 or 11/12/2011. If any of the dates within that range equal the table dates I will color code that entry different.

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Inspiring
Nov 9, 2011 12:56 PM UTC

If you are on CF9, the ternary operator will work quite nicely.

Translate
siriivenAuthor
Inspiring
Nov 9, 2011 12:58 PM UTC

I'm actually in CF9 on our development server but CF8 in prod and test still where I need to set this up. That does sound interesting and I'll have to keep that in mind for future development. Is there a way in CF8 to do this?

Translate
Inspiring
Nov 9, 2011 2:02 PM UTC

Either

<tr bgcolor=<cfif something>colour1<cfelse>colour2</cfif>

or

<tr valign="top" bgcolor="#iif(condition goes here, de('colour1'), de(colour2))#">

Translate