• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

Format Text Based on Date

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,"&")>
</cfif>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<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;
}
-->
</style>
</head>

<body>

<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">
  <tr>
    <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>
  </tr>
  <cfoutput query="FollowupContacts" startRow="#StartRow_FollowupContacts#" maxRows="#MaxRows_FollowupContacts#">
    <tr>
      <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">
          <p>
            <input type="submit" name="Submit" value="View CCR">
            <input name="P1" type="hidden" id="P1" value="#FollowupContacts.VisitReportID#">
            </p>
          </div>
      </form></td>
      <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>
    </tr>
  </cfoutput>
</table>
<span class="style1"><br>
</span>
<table border="0" width="50%" align="center">
  <cfoutput>
    <tr>
      <td width="23%" align="center" class="style1"><cfif PageNum_FollowupContacts GT 1>
          <a href="#CurrentPage#?PageNum_FollowupContacts=1#QueryString_FollowupContacts#">First</a>
        </cfif>
      </td>
      <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>
        </cfif>
      </td>
      <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>
        </cfif>
      </td>
      <td width="23%" align="center" class="style1"><cfif PageNum_FollowupContacts LT TotalPages_FollowupContacts>
          <a href="#CurrentPage#?PageNum_FollowupContacts=#TotalPages_FollowupContacts##QueryString_FollowupContacts#">Last</a>
        </cfif>
      </td>
    </tr>
  </cfoutput>
</table>
<cfoutput><span class="style1">Records #StartRow_FollowupContacts# to #EndRow_FollowupContacts# of #FollowupContacts.RecordCount# </span></cfoutput>
</body>
</html>
0
sr_millar
Asked:
sr_millar
1 Solution
 
Ryan ChongCommented:
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">
            <cfelse>
                  <cfset color = "##000000">
            </cfif>            
      <td class="style1"><div align="center"><font color="#color#">#LSDateFormat(FollowupContacts.ByWhen,'DD
          MMMM YYYY')# </font></div></td>

...

Hope this helps, regards
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now