Format Text Based on Date

Posted on 2005-05-13
Last Modified: 2010-04-25
Hi all,

I am using DreamWeaver and Coldfusion.  I have a site that lists outstanding action items.  I would like to be able to make dates which are before today appear in red to make them stand out.

Is there a coding solution to this?

Here is my page code in case it is needed, the field in question is called ByWhen:

<cfparam name="URL.ByWhom" default="1">
<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfparam name="PageNum_FollowupContacts" default="1">
<cfquery name="FollowupContacts" datasource="UKContacts">
SELECT VisitReportID, FollowupID, Item, Details, ByWhom, ByWhen, ActionCompleted
FROM FollowUpTable
WHERE ActionCompleted = 0 and ByWhom = '#URL.ByWhom#'
ORDER BY ByWhen DESC</cfquery>
<cfset MaxRows_FollowupContacts=10>
<cfset StartRow_FollowupContacts=Min((PageNum_FollowupContacts-1)*MaxRows_FollowupContacts+1,Max(FollowupContacts.RecordCount,1))>
<cfset EndRow_FollowupContacts=Min(StartRow_FollowupContacts+MaxRows_FollowupContacts-1,FollowupContacts.RecordCount)>
<cfset TotalPages_FollowupContacts=Ceiling(FollowupContacts.RecordCount/MaxRows_FollowupContacts)>
<cfset QueryString_FollowupContacts=Iif(CGI.QUERY_STRING NEQ "",DE("&"&XMLFormat(CGI.QUERY_STRING)),DE(""))>
<cfset tempPos=ListContainsNoCase(QueryString_FollowupContacts,"PageNum_FollowupContacts=","&")>
<cfset ActionCompleted_Checked ="">
<cfif tempPos NEQ 0>
  <cfset QueryString_FollowupContacts=ListDeleteAt(QueryString_FollowupContacts,tempPos,"&")>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style2 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; }
.style3 {
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 10px;
      font-weight: bold;


<p align="center" class="style1">All Outstanding Follow Up Actions for <strong><cfoutput>#FollowupContacts.ByWhom#</cfoutput></strong></p>
<p align="center" class="style3">Please note if you select to view the CCR, please use your back button on the browser to return to this page. </p>
<p class="style1">&nbsp;</p>

<table border="1" align="center">
    <td class="style2"><div align="center">Click Action ID to Edit CCR </div></td>
    <td class="style2"><div align="center">View CCR Relating to Action </div></td>
    <td class="style2"><div align="center">Item</div></td>
    <td class="style2"><div align="center">Details</div></td>
    <td class="style2"><div align="center">Owner</div></td>
    <td class="style2"><div align="center">By When</div></td>
  <cfoutput query="FollowupContacts" startRow="#StartRow_FollowupContacts#" maxRows="#MaxRows_FollowupContacts#">
      <td class="style1"><div align="center"><a href="actionedit.cfm?recordID=#FollowupContacts.FollowupID#">#FollowupContacts.FollowupID#</a></div></td>
      <td class="style1"><form name="form1" method="post" action="rpts/cvr/cvrmain-dynamic-cee.asp">
        <div align="center">
            <input type="submit" name="Submit" value="View CCR">
            <input name="P1" type="hidden" id="P1" value="#FollowupContacts.VisitReportID#">
      <td width="15" class="style1"><div align="center">#FollowupContacts.Item# </div></td>
      <td class="style1">#FollowupContacts.Details# </td>
      <td class="style1"><div align="center">#FollowupContacts.ByWhom# </div></td>
      <td class="style1"><div align="center">#LSDateFormat(FollowupContacts.ByWhen,'DD MMMM YYYY')# </div></td>
<span class="style1"><br>
<table border="0" width="50%" align="center">
      <td width="23%" align="center" class="style1"><cfif PageNum_FollowupContacts GT 1>
          <a href="#CurrentPage#?PageNum_FollowupContacts=1#QueryString_FollowupContacts#">First</a>
      <td width="31%" align="center" class="style1"><cfif PageNum_FollowupContacts GT 1>
          <a href="#CurrentPage#?PageNum_FollowupContacts=#Max(DecrementValue(PageNum_FollowupContacts),1)##QueryString_FollowupContacts#">Previous</a>
      <td width="23%" align="center" class="style1"><cfif PageNum_FollowupContacts LT TotalPages_FollowupContacts>
          <a href="#CurrentPage#?PageNum_FollowupContacts=#Min(IncrementValue(PageNum_FollowupContacts),TotalPages_FollowupContacts)##QueryString_FollowupContacts#">Next</a>
      <td width="23%" align="center" class="style1"><cfif PageNum_FollowupContacts LT TotalPages_FollowupContacts>
          <a href="#CurrentPage#?PageNum_FollowupContacts=#TotalPages_FollowupContacts##QueryString_FollowupContacts#">Last</a>
<cfoutput><span class="style1">Records #StartRow_FollowupContacts# to #EndRow_FollowupContacts# of #FollowupContacts.RecordCount# </span></cfoutput>
Question by:sr_millar
    1 Comment
    LVL 48

    Accepted Solution

    You can try use the DateDiff function to determine whether a date is smaller than today or not, and then set the display color accordingly.

    DateDiff("datepart", "date1", "date2")

    try like:


    <cfif DateDiff("d", FollowupContacts.ByWhen, Now()) gt 0>
                      <cfset color = "##FF0000">
                      <cfset color = "##000000">
          <td class="style1"><div align="center"><font color="#color#">#LSDateFormat(FollowupContacts.ByWhen,'DD
              MMMM YYYY')# </font></div></td>


    Hope this helps, regards

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
    Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now