Link to home
Start Free TrialLog in
Avatar of sr_millar
sr_millar

asked on

UK Date Format in DW

Hi,

I have setup a site which a page which displays data from an Access database.  I have saved the page as all.cfm (i have coldfusion running on the server) and when I view the date column on the page it displays 2005-03-10 00:00:00 for example.  How can I make it display 10/03/2005 (dd/mm/yyyy)

Any help would be great.

Stuart
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

You may need to try the DateFormat Fuction, like:

<cfset todayDate = Now()>
<body>
<h3>DateFormat Example</h3>
<p>Today's date is <cfoutput>#todayDate#</cfoutput>.
<p>Using DateFormat, we can display that date in different ways:
<cfoutput>
<ul>
  <li>#DateFormat(todayDate)#
  <li>#DateFormat(todayDate, "mmm-dd-yyyy")#
  <li>#DateFormat(todayDate, "mmmm d, yyyy")#
  <li>#DateFormat(todayDate, "mm/dd/yyyy")#
  <li>#DateFormat(todayDate, "dd/mm/yyyy")#
  <li>#DateFormat(todayDate, "d-mmm-yyyy")#  
  <li>#DateFormat(todayDate, "ddd, mmmm dd, yyyy")#  
  <li>#DateFormat(todayDate, "d/m/yy")#
</ul>  
</cfoutput>

cheers
Avatar of sr_millar
sr_millar

ASKER

Hi,

Thanks for answering:

Here is the code for my page,as you can see the date is put in the table by DW - I used the application object option to insert the dbase results.  Can you tell me how I amend my code with your function to disply the date column as dd/mm/yyyy?

<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfparam name="PageNum_All" default="1">
<cfquery name="All" datasource="QTS">

SELECT BusinessUnit, QuoteNo, MonthYear, QuoteDate, Company, Existing, ContPerson, Description, EquipCode, EndUseLoc, Status, IfLostTo, Comments, DayRateCurr, DayRateSter, PriceBook, DiscountRate, LongTermCalc, Period36912, Basis146198, Commission, CommisonRate, Agent, Probability
FROM Results
ORDER BY QuoteDate DESC
</cfquery>
<cfset MaxRows_All=10>
<cfset StartRow_All=Min((PageNum_All-1)*MaxRows_All+1,Max(All.RecordCount,1))>
<cfset EndRow_All=Min(StartRow_All+MaxRows_All-1,All.RecordCount)>
<cfset TotalPages_All=Ceiling(All.RecordCount/MaxRows_All)>
<cfset QueryString_All=Iif(CGI.QUERY_STRING NEQ "",DE("&"&XMLFormat(CGI.QUERY_STRING)),DE(""))>
<cfset tempPos=ListContainsNoCase(QueryString_All,"PageNum_All=","&")>
<cfif tempPos NEQ 0>
  <cfset QueryString_All=ListDeleteAt(QueryString_All,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>
</head>

<body>
<table border="1" align="center">
  <tr>
    <td>BusinessUnit</td>
    <td>QuoteNo</td>
    <td>MonthYear</td>
    <td>QuoteDate</td>
    <td>Company</td>
    <td>Existing</td>
    <td>ContPerson</td>
    <td>Description</td>
    <td>EquipCode</td>
    <td>EndUseLoc</td>
    <td>Status</td>
    <td>IfLostTo</td>
    <td>Comments</td>
    <td>DayRateCurr</td>
    <td>DayRateSter</td>
    <td>PriceBook</td>
    <td>DiscountRate</td>
    <td>LongTermCalc</td>
    <td>Period36912</td>
    <td>Basis146198</td>
    <td>Commission</td>
    <td>CommisonRate</td>
    <td>Agent</td>
    <td>Probability</td>
  </tr>
  <cfoutput query="All" startRow="#StartRow_All#" maxRows="#MaxRows_All#">
    <tr>
      <td><a href="allquotes.cfm?recordID=#All.BusinessUnit#">#All.BusinessUnit# </a></td>
      <td>#All.QuoteNo# </td>
      <td>#All.MonthYear# </td>
      <td>#All.QuoteDate# </td>
      <td>#All.Company# </td>
      <td>#All.Existing# </td>
      <td>#All.ContPerson# </td>
      <td>#All.Description# </td>
      <td>#All.EquipCode# </td>
      <td>#All.EndUseLoc# </td>
      <td>#All.Status# </td>
      <td>#All.IfLostTo# </td>
      <td>#All.Comments# </td>
      <td>#All.DayRateCurr# </td>
      <td>#All.DayRateSter# </td>
      <td>#All.PriceBook# </td>
      <td>#All.DiscountRate# </td>
      <td>#All.LongTermCalc# </td>
      <td>#All.Period36912# </td>
      <td>#All.Basis146198# </td>
      <td>#All.Commission# </td>
      <td>#All.CommisonRate# </td>
      <td>#All.Agent# </td>
      <td>#All.Probability# </td>
    </tr>
  </cfoutput>
</table>
<br>
<table border="0" width="50%" align="center">
  <cfoutput>
    <tr>
      <td width="23%" align="center"><cfif PageNum_All GT 1>
          <a href="#CurrentPage#?PageNum_All=1#QueryString_All#">First</a>
        </cfif>
      </td>
      <td width="31%" align="center"><cfif PageNum_All GT 1>
          <a href="#CurrentPage#?PageNum_All=#Max(DecrementValue(PageNum_All),1)##QueryString_All#">Previous</a>
        </cfif>
      </td>
      <td width="23%" align="center"><cfif PageNum_All LT TotalPages_All>
          <a href="#CurrentPage#?PageNum_All=#Min(IncrementValue(PageNum_All),TotalPages_All)##QueryString_All#">Next</a>
        </cfif>
      </td>
      <td width="23%" align="center"><cfif PageNum_All LT TotalPages_All>
          <a href="#CurrentPage#?PageNum_All=#TotalPages_All##QueryString_All#">Last</a>
        </cfif>
      </td>
    </tr>
  </cfoutput>
</table>
<cfoutput>Records #StartRow_All# to #EndRow_All# of #All.RecordCount# </cfoutput>
</body>
</html>
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Spot on, worked first time - many thanks.