Skip to main content
Inspiring
November 9, 2011
Question

What is the best way to check date range?

  • November 9, 2011
  • 1 reply
  • 969 views

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 has been closed for replies.

1 reply

Inspiring
November 9, 2011

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

siriivenAuthor
Inspiring
November 9, 2011

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?

Inspiring
November 9, 2011

Either

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

or

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